souporserious / react-measure

📏 Compute measurements of a React component.
https://souporserious.github.io/react-measure/
MIT License
1.94k stars 109 forks source link

componentWillMount causes React.StrictMode to error #120

Closed rpearce closed 5 years ago

rpearce commented 5 years ago

As per https://reactjs.org/docs/strict-mode.html#identifying-unsafe-lifecycles, I believe the following code is causing React apps using React.StrictMode to error, saying that this should be converted to the safer componentDidMount:

https://github.com/souporserious/react-measure/blob/350c5ce653b0b30d800a854e6ae8433eb703ed93/src/with-content-rect.js#L31-L34

I'm not familiar with this library, but it seems like these could perhaps live in a constructor function?

If you think I'm on the right track, I'm happy to try a PR.

souporserious commented 5 years ago

Yup! These should work fine in a constructor method. If you'd like to create a PR, I can review it and get it released. Thank you for filing an issue and being willing to make a PR! 🙏

souporserious commented 5 years ago

Actually, you should be able to just add these as properties on the class, even easier ✨.

rpearce commented 5 years ago

Rock on. I'll see if I can get something up tonight

rpearce commented 5 years ago

@souporserious are you sure the README is up to date for getting set up? Couple of things:

Any help for getting set up would be appreciated!

rpearce commented 5 years ago

You can probably reproduce this if you remove your node_modules/ folder and install from scratch

rpearce commented 5 years ago

@souporserious Do you yet know when your next release will be?

souporserious commented 5 years ago

Apologies for the delay! I was on vacation and then needed to finish the PR that cleaned up the build system. It's published under 2.2.1 now. Thanks for the help! 🙏

rpearce commented 5 years ago

Thank you! Hope your vacation was excellent