react-aiwriter icon indicating copy to clipboard operation
react-aiwriter copied to clipboard

React throws unique "key" prop warning when using multiple tags like <div> inside <AIWriter>

Open malaccan opened this issue 2 years ago • 2 comments

AIWriter works awesome, but it gives the warning below when i use multiple tags like this:

This is a test
Another line

[Error] Warning: Each child in a list should have a unique "key" prop. See https://reactjs.org/link/warning-keys for more information.

malaccan avatar Apr 29 '23 06:04 malaccan

you should add a unique key or id to every div when you are rendering your div

007AnupamSharma avatar May 10 '23 08:05 007AnupamSharma

even with the keys added, react gives the same warning error. it can be reproduced with this example:

<AIWriter>
    <div key="1">some word</div>
    <div key="2">more text</div>
</AIWriter>

produces error:

[Error] Warning: Each child in a list should have a unique "key" prop.
See https://reactjs.org/link/warning-keys for more information.

the error goes away only if there is a single <div> component within the <AIWriter> block. however, AIWriter does not process <br/> for line breaks, so trying to replace multiple <div> with <br/> doesn't work as well.

thanks

malaccan avatar May 25 '23 10:05 malaccan