dillon1000/react

Commit

Always reassign _key for every pass

Currently we're mutating _key. Mutation here is fine, but it needs to
be idempotent - which it's not. This is causing some issues.

Instead I reassign the _key every time it passes through a flattening.
This means that it's unique and stable for a single pass through a composite
component. When it's repassed another level, it loses it previous
identity and is rekeyed by it's new location.

For auto-generated keys by index, this actually means it has the same
semantics as before flattening.

For explicit keys, it has the effect that keys need to be unique at
every level. Regardless of how the key got there. Every component needs to ensure
that it doesn't combine keys from two different sources that may collide. This
is also inline with the old semantics but less intuitive in the new model.
Browse files
Changed paths3 files
First-parent comparison
M src/core/ReactComponent.js ModifiedM src/core/__tests__/ReactIdentity-test.js ModifiedM src/utils/mapChildren.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…