jonathantneal / flexibility

A JavaScript polyfill for Flexbox
https://jonathantneal.github.io/flexibility/
MIT License
4.33k stars 479 forks source link

how to use with reactjs #82

Open gmchaturvedi1 opened 7 years ago

gmchaturvedi1 commented 7 years ago

can u please guide me how to use this with reacrtjs

joekrie commented 7 years ago

Can you provide details on your build setup (e.g., webpack, SystemJS, Babel CLI, etc)?

cdtinney commented 7 years ago

I'm also looking for the 'right' way to do this.

I'm using Webpack with Babel and SCSS.

I tried importing the module, and calling walk as per #57 but was receiving an error about walk not being defined unless I called init beforehand.

Should init be called on each component, or shouldflexibility just be imported and init'ed on the root component?

lachiet commented 7 years ago

flexibility.init was undefined for me because the js is minified when installing via npm but managed to get this working by doing the following...

Call the function on the root component:

componentDidMount() {
    flexibility(document.body).
}

If using react-router you'll need to call this function every time you change page:

update() {
    flexibility(document.body);
}

// somewhere in render function
<Router history={browserHistory} onUpdate={this.update}>