How to generate unique html ids in React
Edit:
I noticed that this approach doesn't work for server-side rendering due to randomness. To solve that issue, React released useId in v18.
TL;DR v2
I published this work. See anilanar/idhook.
TL;DR v1
npm install nanoid
and then use this hook:
i...
anilanar.hashnode.dev2 min read