Skip to content
Prev Previous commit
chore: tidy ups
  • Loading branch information
joshuaellis committed May 4, 2022
commit f3f11ba4ffd581712eab108822edb49e9737035a
2 changes: 1 addition & 1 deletion demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vite/client", "react-dom/next"],
"types": ["vite/client"],
"allowJs": true,
"skipLibCheck": false,
"esModuleInterop": false,
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/hooks/useTransition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ export function useTransition(
usedTransitions.current = transitions
})

// Destroy all transitions on dismount.
useOnce(() => {
/**
* This _should_ only run in `StrictMode` where everything
* is destroyed and remounted, because the enter animation
* was most likely cancelled we run it again on initial mount.
*
* This does nothing when `StrictMode` isn't enabled,
* because usedTransitions on mount is typically null.
*/
each(usedTransitions.current!, t => {
t.ctrl.ref?.add(t.ctrl)
const change = changes.get(t)
Expand All @@ -112,6 +119,7 @@ export function useTransition(
}
})

// Destroy all transitions on dismount.
return () => {
each(usedTransitions.current!, t => {
if (t.expired) {
Expand Down