Best practices for creating globally accessible shared values? #4529
-
I'm trying to make a shared value accessible globally. Is the best practice to use React Context? Is it possible to create shared values outside of React (eg: createSharedValue vs useSharedValue)? This would be very useful for working with state solutions like Zustand or Valtio. Thanks in advance for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hey @jerryjfwang
Yep, this should work.
Nope, this is not officially supported. Technically, you could use |
Beta Was this translation helpful? Give feedback.
-
Context is giving me a mixed experience. Some components that hook into it, don't animate properly unless I save the file and trigger a fast refresh. It starts to work as expected afterwards @tomekzaw |
Beta Was this translation helpful? Give feedback.
Hey @jerryjfwang
Yep, this should work.
Nope, this is not officially supported. Technically, you could use
makeMutable
but it's not a part of public API so we give no guarantees and things may break.