Skip to content

Initializing a shared value outside of component tree #5173

Answered by MatiPl01
yukta357 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

If you want to initialize the shared value outside of the component, you can use the makeMutable function that is used internally by the useSharedValue hook.

It is not documented yet and it is generally not recommended to use makeMutable as it's API may change over time between reanimated versions but it is the only way to suit your needs.

Example code:

const globalSharedValue = makeMutable(0);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MatiPl01
Comment options

@AdamGerthel
Comment options

Answer selected by MatiPl01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants