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

useLayoutEffect seldomly creating long render time with React's renderToPipeableStream in SSR #303

Open
timwuhaotian opened this issue May 8, 2024 · 0 comments

Comments

@timwuhaotian
Copy link

timwuhaotian commented May 8, 2024

  • The onShellReady and onAllReady both hits > 4 seconds 1 out of 10 times with using useWindowSize and useOrientation hook

  • 90% of the time, the time is < 100ms

  • after replace them with local implementation which uses useEffect, the long render time does not happen again.

https://react.dev/reference/react-dom/server/renderToPipeableStream

    "react": "^18.2.0",
    "react-dom": "^18.2.0",

It generates the warning as well:

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
@timwuhaotian timwuhaotian changed the title useLayoutEffect seldomly creating long render time with React's renderToPipeableStream useLayoutEffect seldomly creating long render time with React's renderToPipeableStream in SSR May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant