-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[POC] unmountRef
prop
#1236
base: master
Are you sure you want to change the base?
[POC] unmountRef
prop
#1236
Conversation
Remove keepMounted on portal child parts Remove unused imports Remove keepMounted prop in tests
Netlify deploy preview |
|
||
const onFinished = useEventCallback(onFinishedParam); | ||
const runOnceAnimationsFinish = useAnimationsFinished(animatedElementRef); | ||
const openRef = useLatestRef(open); | ||
|
||
useEnhancedEffect(() => { | ||
React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to regular useEffect
as the timing lets Motion know the exit animation styles have been applied inside a single requestAnimationFrame
when checking for element.getAnimations()
when keepMounted=true
}); | ||
|
||
React.useImperativeHandle(params.unmountRef, () => ({ unmount: handleUnmount }), [handleUnmount]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An API with a bunch of imperative methods could be useful in general, not just for this, so it could be named something more generic to future-proof it. This concept may be similar to using hooks, or component stores as in Ariakit. One difference is you can't "read" values in render, it's just for accessing internal methods/state inside event handlers & effects (since it's a ref).
Closes #1160
Branched off #1222 (diff of only these changes)
JavaScript animations page. I focused on
Motion
fairly exclusively. TheunmountRef
is for when animatingopacity
doesn't work in other libraries for the most part, asopacity: 0.9999
is really the simplest solution.Motion experiments
Adding the
onAnimationComplete
prop results in this warning when composingmotion.div
withPopup
, which seems odd: