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

[Bug]: useLayoutEffect warnings from DataTable in SSR usage #14936

Closed
2 tasks done
ecrvich opened this issue Oct 17, 2023 · 1 comment · Fixed by #15025
Closed
2 tasks done

[Bug]: useLayoutEffect warnings from DataTable in SSR usage #14936

ecrvich opened this issue Oct 17, 2023 · 1 comment · Fixed by #15025

Comments

@ecrvich
Copy link

ecrvich commented Oct 17, 2023

Package

@carbon/react

Browser

No response

Package version

1.40

React version

17

Description

Our console log is blowing up with these exceptions from DataTable nowadays (just upgraded from 1.20 to 1.40):

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://reactjs.org/link/uselayouteffect-ssr for common fixes.
    at Table (c:\GitClones\CDD-Hub\node_modules\@carbon\react\lib\components\DataTable\Table.js:58:5)
    at div
    at TableContainer (c:\GitClones\CDD-Hub\node_modules\@carbon\react\lib\components\DataTable\TableContainer.js:28:5)
    at DataTable (c:\GitClones\CDD-Hub\node_modules\@carbon\react\lib\components\DataTable\DataTable.js:94:5)

Reproduction/example

I think you just need to use DataTable with some SSR framework like Remix or Next.js

Steps to reproduce

Pretty sure all you need to do is be using SSR with DataTable, this appears to be a generic useLayoutEffect drawback. You can read about solutions here:

https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85

Suggested Severity

Severity 4 = Unrelated to a user task, has a workaround or does not need a workaround.

Application/PAL

No response

Code of Conduct

@tay1orjones
Copy link
Member

@ecrvich Thanks for pointing this out. In this case we can probably fix the issue by converting these two usages to use our internal useIsomorphicEffect helper instead of useLayoutEffect.

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

Successfully merging a pull request may close this issue.

3 participants