-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(client components): add use client
directive at the top of files having client components
#4738
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
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:
|
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.
Thanks. I think there are still a couple of places missing like:
useIsFetching
useIsMutating
- the devtools
- the
react-query-persist
package
not sure where all the conflicts are coming from. can you update with main once more please? |
4a66cda
to
7eb2223
Compare
Sure, I have removed the conflicts. |
Codecov ReportBase: 96.36% // Head: 91.25% // Decreases project coverage by
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 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
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.tsx
is definitely a client component- isRestoring.tsx` has react context
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 |
oh yeah, good idea. I think in v5 the |
I took the liberty of removing the 'use client'
import * as React from 'react'
const IsRestoringContext = React.createContext(false)
export const useIsRestoring = () => React.useContext(IsRestoringContext)
export const IsRestoringProvider = IsRestoringContext.Provider Any 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.