-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
useLayoutEffect does nothing on the server #3163
Comments
For now I've fixed this by using the following snippet wherever I use slate.js: // TODO: Remove @slate.js update
// Prevent annoying error messages because
// slate has not updated their library to be SSR ready
if (typeof process !== 'undefined' && process.browser !== true) {
React.useLayoutEffect = React.useEffect;
}
|
Note: This error occurs because I have a library which contains all of my components. My structure is something like this:
Then when I do: import { MySlateComponent } from '@my-corp/library-of-components' I get these hook errors, I do not get these errors when I move the file into my main project. |
Fixed by adding: ...
resolve: {
alias: {
react: require.resolve('react')
}
}
... To my projects webpack configuration. |
Do you want to request a feature or report a bug?
Bug report
What's the current behavior?
I see the information about a working JS fiddle, but since this is a Server Side Rendering issue, I'll not be able to do that easily. Basically run any test (jest) or run a next.js render against any of the new slate.js components and you'll get a lot of error spam in your console.
I've created a small gist, which can be found here.
What's the expected behavior?
That slate.js will render on Server Side Rendering
The text was updated successfully, but these errors were encountered: