Replies: 1 comment
-
@rhinck Thanks for asking! Yes, this is an intended behavior. If you wish to reset the shared value on each hot reload, you might wanna consider resetting the shared value in an effect like this: useEffect(() => {
top.value = 600; // reset shared value on hot reload
}, []); You can also use the same trick to restart an animation on each fast refresh: useEffect(() => {
top.value = 600;
top.value = withTiming(700);
}, []); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone 👋
I just wanted to confirm whether this is intended behavior or not.
When I change the initial value of a shared value, the new default doesn’t seem to take effect after saving — it only updates after a full reload (pressing r in Expo CLI).
Example
const top = useSharedValue(600);
If I change that to 650 and save, nothing moves until I manually reload the app (Expo SDK 54).
Question
Is this the expected behavior — for example, that useSharedValue persists its state in memory across hot reloads — or should hot reloads also re-initialize the default value?
Thanks in advance for clarifying! 🙏
Beta Was this translation helpful? Give feedback.
All reactions