Commit 19a6337
committed
Execute event handlers in the context of the instance that it's associated with (#29876)
That way we get owner stacks (native or otherwise) for `console.error`
or `console.warn` inside of them.
Since the `reportError` is also called within this context, we also get
them for errors thrown within event listeners. You'll also be able to
observe this in in the `error` event. Similar to how `onUncaughtError`
is in the scope of the instance that errored - even though
`onUncaughtError` doesn't kick in for event listeners.
Chrome (from console.createTask):
<img width="306" alt="Screenshot 2024-06-12 at 2 08 19 PM"
src="https://github.com/facebook/react/assets/63648/34cd9d57-0df4-44df-a470-e89a5dd1b07d">
<img width="302" alt="Screenshot 2024-06-12 at 2 03 32 PM"
src="https://github.com/facebook/react/assets/63648/678117b1-e03a-47d4-9989-8350212c8135">
Firefox (from React DevTools):
<img width="493" alt="Screenshot 2024-06-12 at 2 05 01 PM"
src="https://github.com/facebook/react/assets/63648/94ca224d-354a-4ec8-a886-5740bcb418e5">
(This is the parent stack since React DevTools doesn't just yet print
owner stack.)
(Firefox doesn't print the component stack for uncaught since we don't
add component stacks for "error" events from React DevTools - just
console.error. Perhaps an oversight.)
If we didn't have the synthetic event system this would kind of just
work natively in Chrome because we have this task active when we attach
the event listeners to the DOM node and async stacks just follow along
that way. In fact, if you attach a manual listener in useEffect you get
this same effect. It's just because we use event delegation that this
doesn't work.
However, if we did get rid of the synthetic event system we'd likely
still want to add a wrapper on the DOM node to set our internal current
owner so that the non-native part of the system still can observe the
active instance. That wouldn't work with manually attached listeners
though.
DiffTrain build for commit 195d5bb.1 parent ff84555 commit 19a6337
File tree
14 files changed
+7520
-7520
lines changed- compiled-rn
- facebook-fbsource/xplat/js
- RKJSModules/vendor/react
- react-test-renderer/cjs
- react/cjs
- react-native-github/Libraries/Renderer
- implementations
14 files changed
+7520
-7520
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
15053 | 15053 | | |
15054 | 15054 | | |
15055 | 15055 | | |
15056 | | - | |
| 15056 | + | |
15057 | 15057 | | |
15058 | 15058 | | |
15059 | 15059 | | |
15060 | 15060 | | |
15061 | 15061 | | |
15062 | 15062 | | |
15063 | | - | |
| 15063 | + | |
15064 | 15064 | | |
15065 | 15065 | | |
15066 | 15066 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
9357 | 9357 | | |
9358 | 9358 | | |
9359 | 9359 | | |
9360 | | - | |
| 9360 | + | |
9361 | 9361 | | |
9362 | 9362 | | |
9363 | 9363 | | |
| |||
9388 | 9388 | | |
9389 | 9389 | | |
9390 | 9390 | | |
9391 | | - | |
| 9391 | + | |
9392 | 9392 | | |
9393 | 9393 | | |
9394 | 9394 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
9979 | 9979 | | |
9980 | 9980 | | |
9981 | 9981 | | |
9982 | | - | |
| 9982 | + | |
9983 | 9983 | | |
9984 | 9984 | | |
9985 | 9985 | | |
| |||
10023 | 10023 | | |
10024 | 10024 | | |
10025 | 10025 | | |
10026 | | - | |
| 10026 | + | |
10027 | 10027 | | |
10028 | 10028 | | |
10029 | 10029 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
1741 | 1741 | | |
1742 | 1742 | | |
1743 | 1743 | | |
1744 | | - | |
| 1744 | + | |
1745 | 1745 | | |
1746 | 1746 | | |
1747 | 1747 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
607 | | - | |
| 607 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
611 | | - | |
| 611 | + | |
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments