Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrictMode breaks Masonry #183

Open
solarlime opened this issue Nov 29, 2023 · 1 comment
Open

StrictMode breaks Masonry #183

solarlime opened this issue Nov 29, 2023 · 1 comment

Comments

@solarlime
Copy link

Hello, everyone!

I tried to use 'react-masonry-component' but found very strange behaviour (as for me). Wrapping with <React.StrictMode> breaks masonry - it does not set any positioning.

Layout with and without StrictMode:
With StrictMode Without StrictMode

Inline styles with and without StrictMode:
With StrictMode
Without StrictMode

It can be fixed by adding { position: relative } to a parent and { position: absolute } to children, but it's a dirty fix: also masonry stops rebuilding on resize, you need to trigger the layout function. Any ideas?

Reproduced in Codesandbox

@hussain-nz
Copy link

hussain-nz commented Feb 23, 2024

Thanks for helping us fix our issue too! We upgraded to React 18 and got the same issue.
Using "position: relative" on the parent's "style" property didn't work. It worked when using a class in className (in our case, tailwind "relative").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants