Hi, can you show how to do animation on navigate screen? because I want to move the screen like flip a book pages but I have no idea on how to achieve this, thx!
You really should avoid using useState for two reasons: 1. Animated methods don't respect the order of execution of React Native hooks because they don't run on the React thread. This means that if you heavily rely on the accuracy of the return value from useState, you would not get the result you want because Animated methods don’t wait for your hooks to finish running. 2. You could enforce usage of useState by wrapping the animation methods with useCallback hooks, but you'd be causing unnecessary renders, since the animations happen independent of React’s hook cycle anyway.
It just gets the `getter` part of the useState. useState returns an array of 2 elements. The first one is the getter and the second one is a function which can be used to set the value of state variable. Since we don't need to manually set the state variable (we'll do that ourselves using the Animated API), we don't need to store the getter function, hence, I directly pick up the first element ([0]).
Hi, can you show how to do animation on navigate screen? because I want to move the screen like flip a book pages but I have no idea on how to achieve this, thx!
what is difference between PanResponder and TapGestureHandler ???
Thank you!
can u do example draw a line from a to b image
why do you prefer to use useState instead of useRef?
You really should avoid using useState for two reasons:
1. Animated methods don't respect the order of execution of React Native hooks because they don't run on the React thread. This means that if you heavily rely on the accuracy of the return value from useState, you would not get the result you want because Animated methods don’t wait for your hooks to finish running.
2. You could enforce usage of useState by wrapping the animation methods with useCallback hooks, but you'd be causing unnecessary renders, since the animations happen independent of React’s hook cycle anyway.
@@D3DDLOCK Using useCallback can use performance drawbacks too. As it is said Premature optimization is the root of all evil 😁😁
what does useState()[0] does?
It just gets the `getter` part of the useState. useState returns an array of 2 elements. The first one is the getter and the second one is a function which can be used to set the value of state variable. Since we don't need to manually set the state variable (we'll do that ourselves using the Animated API), we don't need to store the getter function, hence, I directly pick up the first element ([0]).