Skip to content
Discussion options

You must be logged in to vote

Hey @mapokapo!

Your suggestion is correct but unnecessarily complicated. We don't have to create a separate function to start the animation. We can just put the SharedValue in the dependency array of the useEffect to satisfy eslint.

So in this case it will be:

const progress = useSharedValue(0);

useEffect(() => {
  progress.value = withDelay(
    2000,
    withSpring(20, {
      mass: 10,
      damping: 40,
    })
  );
}, [progress]); // <-- just add the `progress` SharedValue here

It is safe to pass all shared values that you use in the dependency array as React performs a shallow comparison of all objects and SharedValues objects don't change during renders so they won't fire the useEf…

Replies: 1 comment 2 replies

Comment options

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

Answer selected by MatiPl01
@mapokapo
Comment options

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