paulcollett / react-masonry-css

React Masonry layout component powered by CSS, dependancy free
https://paulcollett.github.io/react-masonry-css/demo/
MIT License
961 stars 66 forks source link

Change "componentWillReceiveProps" to componentDidUpdate #27

Closed sampolahtinen closed 5 years ago

sampolahtinen commented 5 years ago

Hi :)

First of all, great work here! I like the simplicity of this package.

Going through the source I noticed that the code still uses componentWillReceiveProps:

https://github.com/paulcollett/react-masonry-css/blob/master/src/react-masonry-css.js

As it is deprecated method, I propose to change it to componentDidUpdate() or alternative method.

I can give it a look if time allows :)

paulcollett commented 5 years ago

I didn't realise, but absolutely. If this is causing warnings at any point during the build, when running we should prioritise this.

This seems to be a good reason to kickstart a full upgrade of the component to use the recommended class syntax, and other React recommendations

eFFeeMMe commented 5 years ago

Hi!

I've been enjoying using your library at work but I've experienced issues related to the deprecated lifecycle hook componentWillReceiveProps.

I wouldn't know how to reproduce the issue outside of our application, but what ended up happening was that columnCount was not consistent with the supplied breakpointCols prop.

We fixed it by moving the execution of this.reCalculateColumnCount() from componentWillReceiveProps to componentDidUpdate. It would be great to see that integrated in your library and I could open a PR for it if that's ok.

patelnav commented 5 years ago

Love the library. Just a heads up if you run the module under React.StrictMode, we get the following warning:

componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead: Masonry

georgedoescode commented 5 years ago

Is anyone working on this ATM? I would definitely be up for it if not!

paulcollett commented 5 years ago

I would definitely be up for it if not!

@georgedoescode PR is very welcomed. I'll merge it asap

paulcollett commented 5 years ago

Fixed in https://github.com/paulcollett/react-masonry-css/pull/36