#12: Pan Responder API - React Native Animations

Поділитися
Вставка
  • Опубліковано 10 гру 2024

КОМЕНТАРІ • 9

  • @wkc328
    @wkc328 4 роки тому +3

    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!

  • @creative-commons-videos
    @creative-commons-videos 4 роки тому +1

    what is difference between PanResponder and TapGestureHandler ???

  • @gradientO
    @gradientO 4 роки тому +2

    Thank you!

  • @kayan_dev
    @kayan_dev 4 роки тому

    can u do example draw a line from a to b image

  • @JuanDeSouza7
    @JuanDeSouza7 4 роки тому +1

    why do you prefer to use useState instead of useRef?

    • @D3DDLOCK
      @D3DDLOCK 4 роки тому +4

      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.

    • @Ayush_kumar123
      @Ayush_kumar123 3 роки тому

      @@D3DDLOCK Using useCallback can use performance drawbacks too. As it is said Premature optimization is the root of all evil 😁😁

  • @admondtamang4119
    @admondtamang4119 4 роки тому

    what does useState()[0] does?

    • @codedamn
      @codedamn  4 роки тому +5

      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]).