-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
kind: bugSomething isn't workingSomething isn't workingtype: help wantedExtra attention is neededExtra attention is needed
Milestone
Description
🐛 Bug Report
const [canShow, setCanShow] = useState(false)
const trans = useTransition(canShow, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 },
})
const showAndHideQuickly = async () => {
setCanShow(true)
await Promise.resolve()
setCanShow(false)
}
return (
<>
<button onClick={showAndHideQuickly}>Show and hide</button>
{trans((style, item) => item && <animated.div style={style} />)}
</>
)
If I change the state ( first argument of useTransition ) from false to true, the component will mount. And I change the state back to false quickly, the component will not unmount.
If the from and leave are different, the component will unmount when the state is false.
To Reproduce
https://codesandbox.io/s/react-spring-bug-m23ir?file=/src/App.js
Expected behavior
the mounting and unmounting should follow the state.
Link to repro (highly encouraged)
https://codesandbox.io/s/react-spring-bug-m23ir?file=/src/App.js
Environment
react-springv9.0.0-rc.3reactv16.13.1
danielberndt, ShiiRochi and hsunpeiriadd
Metadata
Metadata
Assignees
Labels
kind: bugSomething isn't workingSomething isn't workingtype: help wantedExtra attention is neededExtra attention is needed