defaultOpen not working on first initial disclosure panel #1770
Replies: 3 comments 2 replies
-
Hey! Thank you for your question! Please provide a reproduction repo or a codesandbox of what you tried so that we can see where things went wrong. |
Beta Was this translation helpful? Give feedback.
-
@RobinMalfait any update for this issue ? |
Beta Was this translation helpful? Give feedback.
-
We are experiencing this issue and can provide a little more context. We're trying to build a feature where if the window.location.hash matches the id of one of the disclosures, that it is open by default on page load. We are using a server rendered framework that cannot access the url hash, so it renders all of the disclosures as defaultOpen=false on the initial page load. In order to avoid the hydration mismatch warnings, we're trying to set defaultOpen after the initial render. But since the defaultOpen prop is only used to initialize the reducer, it doesn't matter on subsequent renders. It'd be great if there was a useEffect wrapping this prop that could trigger an open event on the reducer if it flips from false to true. Any thoughts on how to solve this use case? We're probably going to have to abandon using the Disclosure component to solve this in its current state. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.6.6
What browser are you using?
Chrome
Describe your issue
I'm trying to make first disclosure panel always to open and can able be close . I tried defaultOpen and static but it doesn't meet my requirements. Kindly request how am i gonna do. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions