useInterpolateMotiPressable()
In the rare case that you want more customization over pressable state, you can use useInterpolateMotiPressable
. As the name implies, it lets you interpolate based on the current interaction state of a parent MotiPressable
.
#
Usage#
Access a unique parentIf you're passing a unique id
prop to your pressable, you can also isolate this hook to that pressable.
Say the parent pressable has id="menu"
, and you want to isolate this hook to the menu
pressable:
Then, in the Item
component:
#
TypeScript supportuseInterpolateMotiPressable
returns an Animated.DerivedValue
. You can also type it with a generic:
#
Use the result of the interpolationJust like any derived value, you can read the value it returns with .value
:
#
PerformanceSimilar to useMemo
, you can also pass in a dependency array as the last argument:
#
APIThe following usages are valid:
If there's a unique MotiPressable component with an id
prop as the parent:
#
Argumentsfactory
is a worklet that receives the interaction state as the first argument, and can return whatever it wants.id
is a unique string to identify the parentMotiPressable
component whose interaction state you're trying to access.deps
is a dependency array, just likeuseMemo
#
ReturnsA derived value, which you can use in Reanimated worklets.