-
Notifications
You must be signed in to change notification settings - Fork 1
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
web-react: Avoid using useLayoutEffect
hook on the server side
#1129
Conversation
✅ Deploy Preview for spirit-design-system-demo canceled.
|
✅ Deploy Preview for spirit-design-system-validations canceled.
|
✅ Deploy Preview for spirit-design-system-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit f548848. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 3 targetsSent with 💌 from NxCloud. |
✅ Deploy Preview for spirit-design-system-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
packages/web-react/src/components/FileUploader/useFileUploaderAttachment.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩
* avoid using `useLayoutEffect` hook on server side * @see https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85 * @see https://usehooks-ts.com/react-hook/use-isomorphic-layout-effect * @see https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a
* to avoid error messages while rendering on the server side
5fe5531
to
f548848
Compare
Description
useLayoutEffect
does not work on the server side, so we must useuseEffect
instead.However we can use both by wrapping them to new
useIsomorphicLayoutEffect
hook which detects the browser environment.Additional context
Issue reference
https://jira.lmc.cz/browse/DS-1004
Before submitting the PR, please make sure you do the following
fixes #123
).