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

React.useId doesn't exist in React 16/17 #20

Closed
s100 opened this issue Nov 14, 2023 · 3 comments
Closed

React.useId doesn't exist in React 16/17 #20

s100 opened this issue Nov 14, 2023 · 3 comments

Comments

@s100
Copy link

s100 commented Nov 14, 2023

PR #16 introduced a dependency on React's useId Hook. Unfortunately this Hook only exists in React 18, not React 16 or 17. react-json-view-lite is still meant to work in React 16, 17 and 18 which means unfortunately this was a breaking change. We still use React 17 (the React 18 upgrade is going to be difficult for us for reasons too complex to explain here) so this change broke us.

For now we are working around this by pinning to react-json-view-lite@1.1.0.

My suggestion would be to temporarily eliminate usage of React.useId and use some other unique ID generator instead, and release this as say react-json-view-lite@1.2.1. Later, if you want to move to use React.useId again, you can formally drop support for React 16 and 17 at the same time, document the breaking change, and bump your major version number to react-json-view-lite@2.

@AnyRoad
Copy link
Owner

AnyRoad commented Nov 15, 2023

Hi! I haven't noticed that the useId Hook exists only in the React 18 😢
Yes, I think the best solution is to eliminate the useId. I don't want to add any dependencies to the library since it was the original goal - to have no dependencies except React itself. But it might be challenging to write correct useId for all use cases (including SSR) from scratch.

I will release 1.2.1 asap.

@AnyRoad
Copy link
Owner

AnyRoad commented Nov 18, 2023

Just released version 1.2.1 without the useId dependency.

@AnyRoad
Copy link
Owner

AnyRoad commented Jan 4, 2025

Starting from the version 2.0.0 React 16/17 support has beed deprecated.

@AnyRoad AnyRoad closed this as completed Jan 4, 2025
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

No branches or pull requests

2 participants