Repository navigation
fix(Reanimated): keep a stable shared value identity in the useSharedValue mock - #10920
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review.
|
…k-shared-value-stable-identity # Conflicts: # packages/react-native-reanimated/src/mock.ts
Note
This pull request was authored by AI on behalf of @pawicao.
Summary
Stacked on #10919.
The real
useSharedValuekeeps one shared value for the lifetime of the component. The Jest mock created a new object on every call, so the shared value changed identity on every render. Code that used it as auseEffectoruseMemodependency ran again on every render under the mock. I moved the mock shared value creation into theuseStateinitializer, so each component keeps one shared value.Test plan
I added a test to
__tests__/mock.useSharedValue.test.tsxthat re-renders the hook and compares the results. Before the fix it failed, after the fix it passes. The full reanimated Jest suite passes.Changelog
yarn changelog:addfor each changed package, or this PR does not changereact-native-reanimatedorreact-native-worklets.