Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: added
useAnimatedValue
hook for internal usage (#97)
## 📜 Description Added `useAnimatedValue` hook for storing `Animated.Value`. For internal usage only. ## 💡 Motivation and Context Variant with: ```ts const value = useRef(new Animated.Value(0)).current; ``` Is not good, since `new Animated.Value(0)` will be recreated on every re-render (it will not have direct pointers so it will be collected by GC, but it's additional job for memory allocation and further deallocation which is not needed in the fact). Variant with: ```ts const [value] = useState(() => new Animated.Value(0)); ``` May also be a not good alternative, since the function inside of `useState` will be re-created on every re-render. So the variant with `useAnimatedValue` hook seems a best candidate for that, since it will create a value only once (on initial render). ## 📢 Changelog ### JS - added `useAnimatedValue` hook for internal usage; ## 🤔 How Has This Been Tested? Tested on iPhone 13 Pro (iOS 15.0) - works as before. ## 📝 Checklist - [x] CI successfully passed
- Loading branch information