1
1
import type { MotiPressableInteractionState } from './types'
2
- import { useDerivedValue } from 'react-native-reanimated'
3
- import type Animated from 'react-native-reanimated'
2
+ import { SharedValue , useDerivedValue } from 'react-native-reanimated'
4
3
import { MotiPressableInteractionIds , useMotiPressableContext } from './context'
5
4
import { useFactory } from './use-validate-factory-or-id'
6
5
7
6
type Factory < Props > = ( interaction : MotiPressableInteractionState ) => Props
7
+ type Deps = unknown [ ] | null | undefined
8
8
9
9
/**
10
10
* `useInterpolateMotiPressable` lets you access the pressable state, and create a reanimated derived value from it.
@@ -74,20 +74,20 @@ type Factory<Props> = (interaction: MotiPressableInteractionState) => Props
74
74
export function useInterpolateMotiPressable < Props > (
75
75
id : MotiPressableInteractionIds [ 'id' ] ,
76
76
factory : Factory < Props > ,
77
- deps ?: readonly any [ ]
78
- ) : Readonly < Animated . SharedValue < Props > >
77
+ deps ?: Deps
78
+ ) : Readonly < SharedValue < Props > >
79
79
export function useInterpolateMotiPressable < Props > (
80
80
factory : Factory < Props > ,
81
- deps ?: readonly any [ ]
82
- ) : Readonly < Animated . SharedValue < Props > >
81
+ deps ?: Deps
82
+ ) : Readonly < SharedValue < Props > >
83
83
export function useInterpolateMotiPressable < Props > (
84
84
factoryOrId : Factory < Props > | MotiPressableInteractionIds [ 'id' ] ,
85
- maybeFactoryOrDeps ?: Factory < Props > | readonly any [ ] ,
86
- maybeDeps ?: readonly any [ ]
87
- ) : Readonly < Animated . SharedValue < Props > > {
85
+ maybeFactoryOrDeps ?: Factory < Props > | Deps ,
86
+ maybeDeps ?: Deps
87
+ ) : Readonly < SharedValue < Props > > {
88
88
const context = useMotiPressableContext ( )
89
89
90
- const { factory, id, deps = [ ] } = useFactory < Factory < Props > > (
90
+ const { factory, id, deps } = useFactory < Factory < Props > > (
91
91
'useMotiPressableAnimatedProps' ,
92
92
factoryOrId ,
93
93
maybeFactoryOrDeps ,
@@ -96,5 +96,5 @@ export function useInterpolateMotiPressable<Props>(
96
96
97
97
return useDerivedValue < Props > ( ( ) => {
98
98
return context && factory ( context . containers [ id ] . value )
99
- } , [ ...deps , context . containers [ id ] ] )
99
+ } , [ ...( deps || [ ] ) , context . containers [ id ] ] )
100
100
}
0 commit comments