diff --git a/example/src/App.tsx b/example/src/App.tsx index 5168660..d521be6 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -6,9 +6,12 @@ import DemoModal from './components/DemoModal' import IntroModal from './components/IntroModal' import IntroButton from './components/IntroButton' -interface Modal { +interface Modal { origin: 'Hooks' | 'Class' | 'Plain JS' - color: C + color: C | 'darkgreen' + // 👆 Comment this one and uncomment that one 👇 to remove all the TypeScript errors + // color: 'lightsalmon' | 'deepskyblue' | 'deeppink' | 'darkgreen' + // Note: the TS errors were left voluntarily to showcase the type inference & autocomplete possibilities name: N } diff --git a/src/lib/ModalStack.tsx b/src/lib/ModalStack.tsx index 35bee73..6eb20bb 100644 --- a/src/lib/ModalStack.tsx +++ b/src/lib/ModalStack.tsx @@ -44,12 +44,10 @@ const ModalStack =

(props: Props

) => { easing: Easing.inOut(Easing.ease), duration: backdropAnimationDuration, useNativeDriver: true, - }).start(({ finished }) => { - if (finished) { - setStackStatus('hidden') - setBackdropClosedItems([]) - translateY.setValue(sh(100)) - } + }).start(() => { + setStackStatus('hidden') + setBackdropClosedItems([]) + translateY.setValue(sh(100)) }) } }, [backdropAnimationDuration, opacity, translateY, stackStatus]) diff --git a/src/lib/StackItem.tsx b/src/lib/StackItem.tsx index 8106464..b690470 100644 --- a/src/lib/StackItem.tsx +++ b/src/lib/StackItem.tsx @@ -129,11 +129,9 @@ const StackItem =

({ toValue, useNativeDriver: true, ...(closeModalCallback ? animateOutConfig : animateInConfig), - }).start(({ finished }) => { - if (finished) { - closeModalCallback?.(stackItem) - modalStackItemCallback?.() - } + }).start(() => { + closeModalCallback?.(stackItem) + modalStackItemCallback?.() }) } }, @@ -203,11 +201,9 @@ const StackItem =

({ toValue, useNativeDriver: true, ...animateOutConfig, - }).start(({ finished }) => { - if (finished) { - onCloseListener.current({ type: 'closeModal', origin: 'fling' }) - closeModal(stackItem) - } + }).start(() => { + onCloseListener.current({ type: 'closeModal', origin: 'fling' }) + closeModal(stackItem) }) } }, diff --git a/src/types.ts b/src/types.ts index fc14d7d..5c35f5c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -269,9 +269,7 @@ export interface ModalOptions { * easing: Easing.inOut(Easing.exp), * useNativeDriver: true, * }), - * ]).start(({ finished }) => { - * if (finished) callback?.() - * }) + * ]).start() => callback?.()) * } * @see [API reference](https://colorfy-software.gitbook.io/react-native-modalfy/api/types/modaloptions#animationin). */ @@ -314,9 +312,7 @@ export interface ModalOptions { * easing: Easing.inOut(Easing.exp), * useNativeDriver: true, * }), - * ]).start(({ finished }) => { - * if (finished) callback() - * }) + * ]).start(() => callback()) * } * @see [API reference](https://colorfy-software.gitbook.io/react-native-modalfy/api/types/modaloptions#animationout). */