Uh oh!
There was an error while loading. Please reload this page.
feat(client components): add use client directive at the top of files having client components - #4738
Conversation
…iles having client components
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a28c5a0:
|
TkDodo
left a comment
There was a problem hiding this comment.
Thanks. I think there are still a couple of places missing like:
useIsFetchinguseIsMutating- the devtools
- the
react-query-persistpackage
TkDodo
commented
Jan 13, 2023
not sure where all the conflicts are coming from. can you update with main once more please? |
4a66cda to
7eb2223Compare
Sure, I have removed the conflicts. |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@## main #4738 +/- ##
==========================================
- Coverage 96.36% 91.25% -5.11%
==========================================
Files 45 110 +65 Lines 2281 4116 +1835 Branches 640 1057 +417 ==========================================
+ Hits 2198 3756 +1558 - Misses 80 339 +259 - Partials 3 21 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TkDodo
left a comment
There was a problem hiding this comment.
there are more things that should be client components. Basically, everything that uses state, effects or context needs to be a client component. I haven't looked at the full list, but:
hydrate.tsxis definitely a client component- isRestoring.tsx` has react context
Ephem
commented
Jan 20, 2023
Thanks for working on this! I finally got around to do some testing, and I actually think we should not include Second, having it in the hooks-only files actually hurts in a sense. If you forget to add But if you have @TkDodo I think this also means we might want to split any file that has both client components and hooks into two separate ones, like |
TkDodo
commented
Jan 20, 2023
oh yeah, good idea. I think in v5 the |
Ephem
commented
Jan 24, 2023
I took the liberty of removing the 'use client'import*asReactfrom'react'constIsRestoringContext=React.createContext(false)exportconstuseIsRestoring=()=>React.useContext(IsRestoringContext)exportconstIsRestoringProvider=IsRestoringContext.ProviderAny such context/useContext pattern will need to be split into two files to get good error messages for the |
use client directive at the top of files having client componentsuse client directive at the top of files having client components

This PR is addressing the improvement suggested in #4689.