How do you avoid putting key prop on all your child elements?


#1

If you are creating a parent component that renders its children, how do you do it in a way where you don’t have to add the key prop to each child? For example:

<Parent>
  <Child1 />
  <Child2 />
</Parent>

If you call children->ReasonReact.array inside of Parent, you will get a warning about not having key props.


#2

You don’t get away from it, you have to do it or it can be a frustrating source of bugs. React Docs