Custom Pressables
The mergeAnimateProp worklet makes it easy to build custom components on top of MotiPressable.
mergeAnimateProp#
Say you want to build a PressableScale component, which changes to scale: 0.96 when it's pressed.
You might start by making it like this:
However, this entirely overrides the animate prop you pass to PressableScale:
That's where mergeAnimateProp comes in. Pass it the interaction state, animate prop, and any overrides you want.
TypeScript#
And in your component:
Usage with Dripsy#
Then, you can use it like so:
In children components#
You can also use mergeAnimateProp in children components, with hooks like useMotiPressable
API#
Arguments#
- interactionrequired: the current interaction state, given to you by the- animateProp.
overrides will always supercede any values in animate.