Closed szydlovsky closed 2 months ago
https://github.com/software-mansion/react-native-reanimated/pull/5942 needs useScrollViewOffset's ref to be nullable - hence the PR. I also checked and a lot of cleanup code in the hook was redundant.
useScrollViewOffset
You can run the following code, it checks both switching between nullable and non-nullable ref, as well as two different scrolls: (add some logs in hook's registering/unregistering to see that cleanups work fine)
Summary
https://github.com/software-mansion/react-native-reanimated/pull/5942 needs
useScrollViewOffset
's ref to be nullable - hence the PR. I also checked and a lot of cleanup code in the hook was redundant.Test plan
You can run the following code, it checks both switching between nullable and non-nullable ref, as well as two different scrolls: (add some logs in hook's registering/unregistering to see that cleanups work fine)
Code
``` TYPESCRIPT import React from 'react'; import Animated, { useAnimatedRef, useDerivedValue, useScrollViewOffset, } from 'react-native-reanimated'; import { Button, StyleSheet, Text, View } from 'react-native'; export default function EmptyExample() { const [refConnected, setRefConnected] = React.useState(false); const [refSwitched, setRefSwitched] = React.useState(false); const aref = useAnimatedRef