mirror of
https://github.com/facebook/react.git
synced 2026-02-26 03:25:25 +00:00
[Fiber] Track the Real Fiber for Key Warnings (#29791)
This refactors key warning to happen inline after we've matched a Fiber. I didn't want to do that originally because it was riskier. But it turns out to be straightforward enough. This lets us use that Fiber as the source of the warning which matters to DevTools because then DevTools can associate it with the right component after it mounts. We can also associate the duplicate key warning with this Fiber. That way we'll get the callsite with the duplicate key on the stack and can associate this warning with the child that had the duplicate. I kept the forked DevTools tests because the warning now is counted on the Child instead of the Parent (18 behavior). However, this won't be released in 19.0.0 so I only test this in whatever the next version is. Doesn't seem worth it to have a test for just the 19.0.0 behavior.
This commit is contained in:
committed by
GitHub
parent
0a5e0b0c2e
commit
a0a435d68f
@@ -1916,11 +1916,9 @@ describe('Store', () => {
|
||||
});
|
||||
|
||||
// In React 19, JSX warnings were moved into the renderer - https://github.com/facebook/react/pull/29088
|
||||
// When the error is emitted, the source fiber of this error is not yet mounted
|
||||
// So DevTools can't connect the error and the fiber
|
||||
// TODO(hoxyq): update RDT to keep track of such fibers
|
||||
// @reactVersion >= 19.0
|
||||
it('from react get counted [React >= 19]', () => {
|
||||
// The warning is moved to the Child instead of the Parent.
|
||||
// @reactVersion >= 19.0.1
|
||||
it('from react get counted [React >= 19.0.1]', () => {
|
||||
function Example() {
|
||||
return [<Child />];
|
||||
}
|
||||
@@ -1936,9 +1934,10 @@ describe('Store', () => {
|
||||
);
|
||||
|
||||
expect(store).toMatchInlineSnapshot(`
|
||||
✕ 1, ⚠ 0
|
||||
[root]
|
||||
▾ <Example>
|
||||
<Child>
|
||||
<Child> ✕
|
||||
`);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user