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

feat: Add support for React 18 and useId #98

Merged
merged 2 commits into from
Sep 13, 2022
Merged

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Sep 6, 2022

The primary motivation is to replace the homegrown useUniqueId() with built-in useId().

I thought to do this conditionally so you can keep supporting older versions. But seems unfortunate to keep bundling that code and might be easier to break. Also, I don't know if it's valid for ESM bundlers to import an export that might not exist.

So I just upgraded the repo to 18 and bumped the peer deps.

}
}, [])
const setExpanded = useCallback(
(n: boolean | ((prev: boolean) => boolean)) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real changes, just had to do this after bumping typings

@roginfarrer
Copy link
Owner

Thanks for the PR, Dan! I'm still curious if we can find a way to continue to support React < v18. I see that MUI has created this solution for conditionally using useId if it's defined, and found a way to make bundlers satisfied with it. What do you think of this? https://github.com/mui/material-ui/blob/e8be92f40a56e0c4b097a6a13291ba761ff1d5c9/packages/mui-utils/src/useId.ts#L20-L35

@gaearon
Copy link
Contributor Author

gaearon commented Sep 9, 2022

Yeah, this seems alright! I'll leave it up to you how to handle this

@roginfarrer roginfarrer changed the title Upgrade for React 18 feat: Add support for React 18 and useId Sep 13, 2022
@roginfarrer roginfarrer merged commit a392620 into roginfarrer:main Sep 13, 2022
@github-actions
Copy link
Contributor

🎉 This PR is included in version 3.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@asharafshahi
Copy link

Seems version 3.4.0 still has to have React 18. For folks that are still on 17, is the fallback support going to be released? Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants