html-react-parser icon indicating copy to clipboard operation
html-react-parser copied to clipboard

Warning: Each child in a list should have a unique "key" prop.

Open tachsin opened this issue 2 years ago • 2 comments

I'm in this kind of a situation where I should pass a unique key to the function, but couldn't do it.

const options = {
      key:"1"
}

{content.map((obj, i) => {
    return <>
        {ReactHtmlParser(somelist[i], options)}
        {obj}
    </>
})}

What is the proper way of doing this?

tachsin avatar Apr 30 '22 07:04 tachsin

I'm in this kind of a situation where I should pass a unique key to the function, but couldn't do it.

const options = {
      key:"1"
}

{content.map((obj, i) => {
    return <>
        {ReactHtmlParser(somelist[i], options)}
        {obj}
    </>
})}

What is the proper way of doing this?

Try this...

<div> {data.map((item, index) => ( <React.Fragment key={index}> {parse(item)} </React.Fragment> ))} </div>

ReinheimerPiano avatar May 25 '22 21:05 ReinheimerPiano

@libensvivit did @ReinheimerPiano's answer help you?

remarkablemark avatar Jun 18 '22 19:06 remarkablemark

Closing issue due to lack of activity. Feel free to reopen if you have additional questions.

remarkablemark avatar Nov 29 '22 05:11 remarkablemark