hooks
hooks copied to clipboard
Add useLayoutAnimation
Summary
This allows you to use LayoutAnimation in a more convenient hook api. It's mainly useful because it removes the need to explicitly enable it on Android everywhere. If necessary, I can also add a function that allows to manually enable/disable this because it would still end up with an easier to use api.
I've added a default animation to the api, which you can override with the same parameters LayoutAnimation.configureNext uses.
Test Plan
example gif

What's required for testing (prerequisites)?
- The expo snack or an iOS/Android simulator.
What are the steps to reproduce (after prerequisites)?
- Open the snack link at the bottom of this PR.
- Use Android or iOS (doesn't work on web afaik).
- Remove an item and see the animation.
You can optionally also set some of the parameters in animateNext.
Compatibility
| OS | Implemented |
|---|---|
| iOS | ✅ |
| Android | ✅ |
| Web | ❌ |
Checklist
- [x] I have tested this on a device and a simulator
- [x] I added the documentation in
README.md - [x] I updated the typed files (TS and Flow) --> Couldn't find these?
- [x] I've created a snack to demonstrate the changes: https://snack.expo.io/@jonivr/uselayoutanimation