Open tim-soft opened 5 years ago
I have to use useLayoutEffect because the component needs to have "mounted" in order for it not to error because that code has to be in the browser to run without an error (I need some kind of container width to know how to resize the photos - to solve for height of row). If you can think of a better way to handle it, PRs or advice welcome. https://reactjs.org/docs/hooks-reference.html#uselayouteffect
I think it's the problem of next or react instead of react-photo-gallery. You can move the component out of ssr to eliminate the warning for the moment.
//import PhotoGallery from "./gallery"; // ssr, which contributes to the warning
const PhotoGallery = dynamic(() => import('./gallery'), { // no ssr
ssr: false
})```
Yep, same issue. Images not rendering sever side and @adam187 PR seems the way to go
For those using hooks, there's a quick solution provided by @gaearon https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
I have to use useLayoutEffect because the component needs to have "mounted" in order for it not to error because that code has to be in the browser to run without an error (I need some kind of container width to know how to resize the photos - to solve for height of row). If you can think of a better way to handle it, PRs or advice welcome. https://reactjs.org/docs/hooks-reference.html#uselayouteffect
I was wondering, will the solution for #144 by adam187 be merged into the master?
I get the following server-side warning in Next.js with react-photo-gallery v8
Here's how to repro:
Add gallery to
pages/index.js
Run the app
You'll get the warning in terminal on every refresh / HMR