fix: use useSyncExternalStore in withUniwind for better compatibility with react lifecycle - #657
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change replaces manual HOC rerender subscriptions with ChangesExternal store updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR improves theme and style update handling for suspended native and web React trees. No actionable merge-blocking risk remains at the current head beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant SuspendedTree
participant React
participant UniwindListener
participant CSSListener
participant HOC
SuspendedTree->>React: suspend rendering
React->>HOC: retain external-store subscription
UniwindListener-->>React: publish updated dependency snapshot
CSSListener-->>React: publish updated class-name snapshot
React->>HOC: re-render after tree reveal
HOC-->>SuspendedTree: apply updated theme and styles
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 6 files. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThe PR migrates
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code correctness or security failures identified. The new snapshots change whenever a currently subscribed native dependency, web theme or variable revision, or relevant media-query match changes, allowing React to reconcile updates missed while a subtree was suspended.
|
| Filename | Overview |
|---|---|
| packages/uniwind/src/core/listener.ts | Adds monotonic per-dependency revisions and snapshot access for native external-store consumers. |
| packages/uniwind/src/core/web/cssListener.ts | Adds a stable snapshot combining theme and variable revisions with relevant media-query states. |
| packages/uniwind/src/hoc/withUniwind.native.tsx | Replaces layout-effect subscriptions with dependency-keyed useSyncExternalStore callbacks. |
| packages/uniwind/src/hoc/withUniwind.tsx | Replaces web HOC effect subscriptions with class-name-keyed external-store subscriptions. |
| packages/uniwind/tests/native/hoc/freeze.test.tsx | Verifies native hooks and HOCs catch up with theme changes after a suspended subtree is revealed. |
| packages/uniwind/tests/web/hoc/freeze.test.tsx | Verifies equivalent suspended-tree recovery for web hooks, wrappers, and mapped props. |
Sequence Diagram
sequenceDiagram
participant Runtime as Uniwind runtime
participant Listener as Platform listener
participant React as useSyncExternalStore
participant HOC as withUniwind component
Runtime->>Listener: Update theme, variables, or media query
Listener->>Listener: Advance/read snapshot
Listener-->>React: Notify subscriber
React->>Listener: Read latest snapshot
React->>HOC: Re-render with current styles
Note over React,HOC: Suspended trees compare snapshots when revealed
Reviews (1): Last reviewed commit: "test: extend freeze tests" | Re-trigger Greptile
|
🚀 This pull request is included in v1.12.0. See Release v1.12.0 for release notes. |
#649
Summary by CodeRabbit
Bug Fixes
Tests