-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix React <Transition>
flicker issue
#1118
Conversation
This pull request is being automatically deployed with Vercel (learn more). headlessui-react – ./packages/playground-react🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/62EppTRzqaq4opm6KpcizFh5fD2W headlessui-vue – ./packages/playground-vue🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/DLQnivi2TVjtBHYRQVWn3fmWsPE5 |
I've still got to update the tests but wanted to be sure I'm not thinking about this wrong. |
What should I do because I am in Iran
در تاریخ شنبه ۱۹ فوریهٔ ۲۰۲۲، ۱:۴۱ Jordan Pittman ***@***.***>
نوشت:
… I've still got to update the tests but wanted to be sure I'm not thinking
about this wrong.
—
Reply to this email directly, view it on GitHub
<#1118 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATMIVVR7TGCV5DIATK6C62LU327Y7ANCNFSM5OZGWJMQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This allows us to guarantee that the ref is always referencing the latest callback. This also allows us to re-run fewer effects because we don't really care about intermediate callback values, just the last one.
21c90df
to
42753ec
Compare
I think I figured it out! (I hope)
Basically the transition component's show defaulted to
true
— which is fine. However, we also have an initial render check. This means that the transition doesn't run on first render. But if you trigger a re-render of children without a change in the show state it'll run the enter transition.This means that:
opacity-0
Then the transition starts and assumes that the element is invisible. This causes the weird animation flicker where it goes from visible to quickly not visible to visible again. The solution is to store the previous show state and only transition if it is actually different.