react-file-icon icon indicating copy to clipboard operation
react-file-icon copied to clipboard

Use React.useId() instead of lodash.uniqueid

Open kensnyder opened this issue 1 year ago • 1 comments

When using SSR (e.g. with Remix or Next) lodash.uniqueid will cause a hydration mismatch warning because the server will have different IDs from the client.

This PR uses React.useId() which returns a unique ID that is stable between client and server. I also omit IDs when jest is defined so that the test snapshots will match.

kensnyder avatar May 16 '24 21:05 kensnyder

@kensnyder Thanks for this! I didn't even know React a function for that. My only concern is it looks like this is will only work in React 18+ (we currently support ^18.0.0 || ^17.0.0 || ^16.2.0). Still debating if it's worth just bumping the major version. 🤔

corygibbons avatar May 23 '24 11:05 corygibbons

Closing in favor of #53.

kensnyder avatar Jun 03 '24 21:06 kensnyder