Skip to content

Commit 513f686

Browse files
committed
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.
1 parent 893ac1f commit 513f686

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

packages/core/src/hooks/useTransition.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,14 @@ export function useTransition(
220220
payload.from = callProp(from, t.item, i)
221221
}
222222

223-
const { onRest }: { onRest?: any } = payload
224-
payload.onRest = result => {
223+
const { onResolve } = payload
224+
payload.onResolve = result => {
225+
callProp(onResolve, result)
226+
225227
const transitions = usedTransitions.current!
226228
const t = transitions.find(t => t.key === key)
227229
if (!t) return
228230

229-
if (is.fun(onRest)) {
230-
onRest(result, t)
231-
}
232-
233231
// Reset the phase of a cancelled enter/leave transition, so it can
234232
// retry the animation on the next render.
235233
if (result.cancelled && t.phase != UPDATE) {

packages/core/src/types/transition.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ export type UseTransitionProps<Item = any> = Merge<
7777
config?:
7878
| SpringConfig
7979
| ((item: Item, index: number) => AnimationProps['config'])
80-
onRest?: (
81-
result: AnimationResult<Controller>,
82-
transition: TransitionState
83-
) => void
8480
/**
8581
* Called after a transition item is unmounted.
8682
*/

0 commit comments

Comments
 (0)