From 11f48aa82e3d1095e099a0a0ba5a7ee3cf43bc61 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Thu, 8 Oct 2020 22:41:04 -0400 Subject: [PATCH] fix: unmount transition items even if `leave` is a noop The `onRest` prop is not called for no-op updates, so we need to use the `onResolve` prop instead. --- packages/core/src/hooks/useTransition.tsx | 10 ++++------ packages/core/src/types/transition.ts | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/core/src/hooks/useTransition.tsx b/packages/core/src/hooks/useTransition.tsx index 87ec1ec7f7..dc68b8b249 100644 --- a/packages/core/src/hooks/useTransition.tsx +++ b/packages/core/src/hooks/useTransition.tsx @@ -220,16 +220,14 @@ export function useTransition( payload.from = callProp(from, t.item, i) } - const { onRest }: { onRest?: any } = payload - payload.onRest = result => { + const { onResolve } = payload + payload.onResolve = result => { + callProp(onResolve, result) + const transitions = usedTransitions.current! const t = transitions.find(t => t.key === key) if (!t) return - if (is.fun(onRest)) { - onRest(result, t) - } - // Reset the phase of a cancelled enter/leave transition, so it can // retry the animation on the next render. if (result.cancelled && t.phase != UPDATE) { diff --git a/packages/core/src/types/transition.ts b/packages/core/src/types/transition.ts index e0081d6526..7a9fffcbfb 100644 --- a/packages/core/src/types/transition.ts +++ b/packages/core/src/types/transition.ts @@ -77,10 +77,6 @@ export type UseTransitionProps = Merge< config?: | SpringConfig | ((item: Item, index: number) => AnimationProps['config']) - onRest?: ( - result: AnimationResult, - transition: TransitionState - ) => void /** * Called after a transition item is unmounted. */