stevelw / fe-nc-news

A portfolio project to showcase frontend development
https://nc-news2024.netlify.app
0 stars 0 forks source link

Keys shouldn't be random #11

Open stevelw opened 2 weeks ago

stevelw commented 2 weeks ago

Keys should be consistent between renders, so random numbers should not be used.

Use a reproducible UUID instead. It's suggested to use https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID

https://github.com/stevelw/fe-nc-news/blob/58f549caa793b0d43b7ca1e8bc68fc2a6a77a4af/src/components/CommentList.jsx#L58

stevelw commented 1 week ago

Use Symbol - JavaScript | MDN to generate keys for React elements?