Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

How do you add a key to a variable map in react.js ? [duplicate]

By M.K. Verma · 2 May 2022

How do you add a key to a variable map in react.js ? [duplicate]
const props = [{
  count: 8
}, {
  count: 7
}, {
  count: 3
}]
const limit = props.map((x, index) => {
  return {
    count: Math.max(x.count, 0),
    key: `elementName${index}`
  }
})

console.log(limit)