plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
481 stars 653 forks source link

useLayoutEffect does nothing on the server #2518

Open avoinea opened 3 years ago

avoinea commented 3 years ago
vendors~client.chunk.js:238131 Warning: useLayoutEffect does nothing on the server, 
because its effect cannot be encoded into
 the server renderer's output format. This will lead to a mismatch between the initial, 
non-hydrated UI and the intended UI. To 
avoid this, useLayoutEffect should only be used in components that render exclusively on the client. 
See https://fb.me/react-uselayouteffect-ssr for common fixes.
    in Provider (at WysiwygWidget.jsx:221)
tiberiuichim commented 3 years ago

https://github.com/eea/volto-slate/blob/master/src/hooks/useIsomorphicLayoutEffect.js

JeffersonBledsoe commented 1 year ago

I've been getting this same error. It's caused by the call to renderToStaticMarkup from on the client side within WYSIWYG widget's edit view whenever you change it's value

edit: Looks like it's actually coming from within react-redux. Likely an interplay between react-redux's implementation of useIsomorphicEffect and it being called from within renderToStaticMarkup on the client. According to the React docs, we should change the method we're using based on whether we're on the client or server: https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup @tiberiuichim This is A little bit past my current understanding of React implementation details, does this sounds about right?

tiberiuichim commented 1 year ago

@JeffersonBledsoe you're unto something, I'll test it.