Thursday, September 15, 2022

Getting, using, passing keys in React

If element is unchangable, use hard-coded key => <div key='custom_key'></div>

<div key={`${Object.keys(arr)}`}></div>

<div key={`item-${index}`}></div>

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys

No comments:

Post a Comment