laleksiunas / inline-svg-unique-id

Efficient ID generator at the runtime for inline SVG components
MIT License
18 stars 3 forks source link

Switch to useId for more consistent SSR #6

Open HosseinAgha opened 1 year ago

HosseinAgha commented 1 year ago

Looks like using React's useId is a more consistent solution for this library. It is isomorphic and covers all SSR and hydration edge cases.

laleksiunas commented 1 year ago

I agree that the built-in useId is a better option going forward. I will migrate to it and publish a major version when I will have more free time in the upcoming months. In the meantime, you can use a provider (see SSR example) to generate correct IDs during SSR.

HosseinAgha commented 1 year ago

I've already cloned the plugin and changed everything to useId(), happy to contribute if you are OK.

laleksiunas commented 1 year ago

Thanks, PRs are welcome

joonaojapalo commented 7 months ago

This package is elegant solution to long standing problem, thank you @laleksiunas ! 👍

I'd be very interested in built-in useId-based id generator and noticed that @HosseinAgha has been working on this. Just wondering if suitability of this work to extend babel-plugin-react-inline-svg-unique-id package could be reviewed in the form of a PR?

I'd see that useId could be set as id generation hook babel-plugin-react-inline-svg-unique-id by configuration property to maintain backward compatibility.