I encountered a duplicate key warning that I did not expect(because it's not a list of the same type of components) for the following:
<Foo key={'baz'} />
<Bar key={'baz'} />
- Why it's totally fine to have the following?
<Foo />
<Bar />
- Why it's problematic for the react fiber to consider component type when handling key uniqueness?
- Could this be because there is some advanced use case where a developer might want to have the same key for different types of components?
It's all clear regarding keys and lists, just curious how it works under the hood.
I think it doesn't matter which component type you would use.
Consider the following code:
If you are iterating in order to create that you will get warnings to provide unique keys for each node inside the parent node.