简体   繁体   中英

React js: initialize ZURB Foundation JS

I am developing a web application with React and Foundation.

Foundation js is initialized by adding $(document).foundation(); .

Any idea how I can initialize my react application with foundation js?

Using the (jQuery based) Foundation JavaScript can lead to a lot of issues.

It's commonly easy to use libraries like react-foundation .

One solution that worked for me is initialize foundation using componentDidMount() function.

class RSAccordion extends React.Component {
    componentDidMount() {
      $(document).foundation()
    }
    render() {
      return (
          //     Your
          //     HTML
          //     Here
      )
    }
  }

This way foundation js is initialized every time the code is rendered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM