fix(hooks): align useIsMobile with the react-hooks/set-state-in-effect#10927
Open
denis-shvets wants to merge 1 commit into
Open
fix(hooks): align useIsMobile with the react-hooks/set-state-in-effect#10927denis-shvets wants to merge 1 commit into
denis-shvets wants to merge 1 commit into
Conversation
Contributor
|
@denis-shvets is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
@shadcn could you take a quick look at this when you get a chance? |
Replaces the setState-in-effect pattern with useSyncExternalStore, React 19's prescribed API for mirroring browser/external state into React. This resolves the hard lint error introduced by the react-hooks/set-state-in-effect rule in eslint-config-next 16.2.5+ and makes the hook compile cleanly under the React 19 Compiler. No public interface changes — drop-in replacement for all callers. - Eliminates boolean | undefined flicker — getSnapshot returns a real boolean on the first client render, no undefined intermediate state - SSR-safe via getServerSnapshot returning false - Tear-free under concurrent rendering (useSyncExternalStore guarantee) - Applied to all four hook copies: apps/v4/hooks and the three registry bases (base, radix, new-york-v4); registry JSON rebuilt accordingly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the
setStateinuseEffectpattern withuseSyncExternalStore, React 19's prescribed API for mirroring browser/external state into React. This resolves the hard lint error introduced by thereact-hooks/set-state-in-effectrule ineslint-config-next16.2.5+ and makes the hook compile cleanly under the React 19 Compiler.ℹ️ No public interface changes. No extra logic added. Drop-in replacement for all callers.
boolean | undefinedflicker -getSnapshotreturns a real boolean on the first client render, no undefined intermediate stategetServerSnapshotreturningfalseuseSyncExternalStoreguarantee)apps/v4/hooksand the three registry bases (base, radix, new-york-v4); registry JSON rebuilt accordinglyFixes: #8739