Access a shared value outside of a functional component #3121
Unanswered
AdamGerthel
asked this question in
Q&A
Replies: 0 comments
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm refactoring parts of an existing app where we're using
Animated.Value
a lot. It allows us to, for example useawait
(basically wrapping animation and callingresolve
in the callback) to hold off some code until an animation has completed. It also allows us to have theAnimated.Value
live outside a component which allows for easy management from stores (that contain business logic) that are not part of the functional components.Is there a way to do something similar with Reanimated 2? I read that we need to use hooks, which are only available in functional components - so it sounds to me like there's no way to start/stop an animation, or wait for it to finish, from outside the component. Or is there?
My use case (simplified for this example) is something like this:
Basically a timeline that moves whenever a new item is added. The previous item becomes inactive after the timeline animation has finished.
Beta Was this translation helpful? Give feedback.
All reactions