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

add: ID for icon cloud to avoid hydration errors #473

Closed
wants to merge 1 commit into from

Conversation

maamokun
Copy link

When using the Icon Cloud component in an SSR framework such as NextJS, the default behaviour of the upstream react-icon-cloud dependency is to use a UUID for the canvas ID. This is a problem, as the UUID will change between the server and the client and cause a hydration error. Since the upstream dependency also allows for changing the ID with the id prop, I think that having that filled as the default for this component and therefore alleviating the issue above will be better, as it is safe to assume that most users of MagicUI will most likey be using some kind of SSR framework.

Copy link

vercel bot commented Dec 27, 2024

@maamokun is attempting to deploy a commit to the product-studio Team on Vercel.

A member of the Team first needs to authorize it.

@teaguestockwell
Copy link
Contributor

teaguestockwell commented Dec 29, 2024

This change might lead to unexpected behavior when 2 clouds render on one page since they would have the same id

@maamokun
Copy link
Author

Then maybe it would be good to have this as a property in the main component

@teaguestockwell
Copy link
Contributor

teaguestockwell commented Dec 29, 2024

Since magicui depends on react 18, I would experiment with React.useId to pass a unique, stable id in the render function of IconCloud. That way it might not need to be passed by the consumer / exposed as a property in the wrapped component.

@dillionverma
Copy link
Collaborator

We just released a new icon cloud component with zero dependencies. This should help address the legacy code issues and make it easier to maintain.

#488

Please try installing the latest one and testing it out. Also if you have any further feedback would be helpful!

https://magicui.design/docs/components/icon-cloud

Going to close issue for now. Feel free to re-open if you still face an issue.

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

Successfully merging this pull request may close these issues.

3 participants