ChakraProvider breaks Suspense in Next.js projects, even without suspended components
See original GitHub issueDescription
When you add ChakraProvider to _app.tsx, any usage of Suspense breaks the app.
Link to Reproduction
https://codesandbox.io/s/nice-wood-50d2lj?file=/pages/index.tsx
Steps to reproduce
- Create a vanilla Next.js app
- Add a Suspense component with
<p>Hello world</p>
as children into pages/index.tsx - Verify it works fine (should)
- Add @chakra-ui/react and
<ChakraProvider>
into _app.tsx - Reload the page - emits the following error:
Error: This Suspense boundary received an update before it finished hydrating. This caused the boundary to switch to client rendering. The usual way to fix this is to wrap the original update in startTransition.
Chakra UI Version
1.8.8 and @next
Browser
No response
Operating System
- macOS
- Windows
- Linux
Additional Information
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:14
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved image ...
Read more >How to Use Chakra UI with Next.js and React - freeCodeCamp
To get a good idea of how Chakra works, we're going to essentially rebuild the default Next.js template with Chakra UI components.
Read more >Fetching and caching Supabase data in Next.js 13 Server ...
Next.js 13 introduces new data fetching and caching methods to enable React Server Components and Suspense.
Read more >Getting Started with Next.js - Chakra UI
A guide for installing Chakra UI with Nextjs projects. ... pages/_app.tsx (create it if it doesn't exist) and wrap the Component with the...
Read more >Building a Mini Next.js - Jonas Galvez
But the massive complexity and dependency tree is still there. You can integrate any Vite-bundled application with Fastify, with any framework ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
setNode(el) in EnvironmentProvider will cause it re-render, and the context value has changed from
defaultEnv
to{ document, window }
React recived an update during streaming rendering react doesn’t know if this update will affect the<ComponentThatSuspend />
componentSo react will have to replace the server HTML with the suspense fallback. This is because it is stale
More detail: https://github.com/reactwg/react-18/discussions/38
I think we need refactor EnvironmentProvider to avoid the top-level updates during the app startup. @segunadebayo
This issue still persists and is still occurring, I tried wrapping my api call with a startTransition but it’s still isn’t working