Skip to content

Regression in null key handling in 0.12 (possibly intentional) #2386

@sophiebits

Description

@sophiebits

In 0.11, the code

<div>
  <div key={null}>foo</div>
  <div key={null}>bar</div>
</div>

assigned implicit keys to both children. In 0.12, it gives the error

Warning: flattenChildren(...): Encountered two children with the same key, .$null. Child keys must be unique; when two children share a key, only the first child will be used.

and renders only "foo", because the key is cast to a string in ReactElement

key = config.key === undefined ? null : '' + config.key;

before it gets checked against null in traverseAllChildren:

if (component && component.key != null) {

I guess it's okay if this is intentional but it broke a part of KA in the upgrade.

@sebmarkbage? (cc @jdan)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions