cedricdelpoux / react-responsive-masonry

React responsive masonry component built with css flexbox
https://cedricdelpoux.github.io/react-responsive-masonry/
MIT License
379 stars 37 forks source link

[REGRESSION] `Masonry2` uses `getDerivedStateFromProps` but its initial state is undefined #131

Open wowblvck opened 4 weeks ago

wowblvck commented 4 weeks ago

After the last update (v.2.4.1) i have a regression bug. On the v2.3.0 it's all works good.

image

rchervot commented 3 weeks ago

Same for me. But I am using Masonry. Also after upgrade to 2.4.1 component started crushing on client. Reverted back to 2.3.0.

Warning: `Masonry` uses `getDerivedStateFromProps` but its initial state is undefined. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `Masonry`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.
    at Masonry (webpack-internal:///(ssr)/./node_modules/react-responsive-masonry/es/Masonry/index.js:22:29)
    at div
    at MasonryResponsive (webpack-internal:///(ssr)/./node_modules/react-responsive-masonry/es/ResponsiveMasonry/index.js:49:36)
    at div
circularchaos commented 3 weeks ago

Same issue here with 2.4.1. Reverting back to 2.3.0 for now resolved the issue as previously mentioned.

wowblvck commented 1 week ago

I want to express my deep gratitude to the author and all those who support this library. Thank you very much for your contribution to its development.

This problem has existed for 2 weeks without the author's attention and since we use this library in our work project, I decided to make my own version of the library based on it and transfer the tools to React 18. I removed all unnecessary tools and tests to cover the features of my project.

This is not advertising or propaganda for switching to my product, this is just a solution for those who also use this library in their projects. I am not going to support or develop it. As soon as I have a little more time, perhaps I will be able to issue a PR. Perhaps the authors of the library will want to apply my solution.

I use Masonry in my projects. We do not use ResponsiveMasonry, so I did not devote time to it and did not test it. Full support for TS.

react-responsive-masonry (npm) github