Skip to content
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

<Transition /> overwrites the className of the child component in SSR #2167

Closed
zero734kr opened this issue Jan 9, 2023 · 8 comments · Fixed by #2173 or #2390
Closed

<Transition /> overwrites the className of the child component in SSR #2167

zero734kr opened this issue Jan 9, 2023 · 8 comments · Fixed by #2173 or #2390
Assignees

Comments

@zero734kr
Copy link

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.7.7

What browser are you using?

Chrome

Reproduction URL

https://codesandbox.io/s/suspicious-mountain-zroyy1?file=/pages/test.jsx

Describe your issue

The transition component is rendering strangely and there is a mismatch between the server and the client due to this.

When the options are as={Fragment}, show={true} and appear=true, in CSR (by clicking next/link in root page) it is working correctly merging child className and the transition props like enterFrom, enter, enterTo. But in SSR, the Transition component replaces the className of the child. In the reproduction URL I attached, the transition component replaced className="relative w-full h-full" with className="opacity-100 translate-x-0".

Warning: Prop className did not match. Server: "transition duration-500 delay-[500ms] opacity-0 translate-x-5" Client: "relative w-full h-full".

I went back to version 1.6.0 but the bug continued, and from 1.5.0 onwards, the component disappeared from the html tree (probably I did something wrong)

@zero734kr
Copy link
Author

👍🎉

@thecrypticace
Copy link
Contributor

Thanks for reporting this! The fix for this has been merged in #2173 and will be available in our next release. In the meantime you can test it before then by using our insiders build: npm install @headlessui/react@insiders

@natedunn
Copy link

natedunn commented Feb 28, 2023

@thecrypticace I might be missing something, but latest version still has this issue? I have it locally, but I can also fork the example provided by @zero734kr, update the package to latest, and still see the same mismatch error described above.

@devgioele
Copy link

devgioele commented Mar 6, 2023

I confirm having the same issue. Even with version 1.7.13. It happens whenever appear is true. I am not using the as prop.

@natedunn
Copy link

@thecrypticace i don't think its worth opening another issue, to prevent confusion. If you can duplicate, can you reopen this issue? Thank you!

@thecrypticace thecrypticace reopened this Mar 16, 2023
@thecrypticace
Copy link
Contributor

I haven't tried to duplicate this yet (sorry!). Re-opening as a reminder for me to look at.

@thecrypticace
Copy link
Contributor

thecrypticace commented Mar 22, 2023

Hey! This should be properly fixed now (via #2390), and will be available in the next release.

You can already try it using npm install @headlessui/react@insiders.

@natedunn
Copy link

@thecrypticace Things are looking good so far are on my end. Thanks for working on this again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants