Skip to content

Commit 19a6337

Browse files
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

14 files changed

+7520
-7520
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.0.0-native-fb-f3e09d6328-20240612
1+
19.0.0-native-fb-195d5bb99e-20240612

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5c8da45929aa14809f5708b12a77bce1>>
10+
* @generated SignedSource<<6cdcb413108c1e621ba982c74574c360>>
1111
*/
1212

1313
"use strict";
@@ -15053,14 +15053,14 @@ __DEV__ &&
1505315053
scheduleRoot: scheduleRoot,
1505415054
setRefreshHandler: setRefreshHandler,
1505515055
getCurrentFiber: getCurrentFiberForDevTools,
15056-
reconcilerVersion: "19.0.0-native-fb-f3e09d6328-20240612"
15056+
reconcilerVersion: "19.0.0-native-fb-195d5bb99e-20240612"
1505715057
});
1505815058
})({
1505915059
findFiberByHostInstance: function () {
1506015060
throw Error("TestRenderer does not support findFiberByHostInstance()");
1506115061
},
1506215062
bundleType: 1,
15063-
version: "19.0.0-native-fb-f3e09d6328-20240612",
15063+
version: "19.0.0-native-fb-195d5bb99e-20240612",
1506415064
rendererPackageName: "react-test-renderer"
1506515065
});
1506615066
exports._Scheduler = Scheduler;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a5f719c3ead8e353daf6a01ac4ffb80b>>
10+
* @generated SignedSource<<26761dd87498d30bb9190a1d55c61aee>>
1111
*/
1212

1313
"use strict";
@@ -9357,7 +9357,7 @@ var devToolsConfig$jscomp$inline_1063 = {
93579357
throw Error("TestRenderer does not support findFiberByHostInstance()");
93589358
},
93599359
bundleType: 0,
9360-
version: "19.0.0-native-fb-f3e09d6328-20240612",
9360+
version: "19.0.0-native-fb-195d5bb99e-20240612",
93619361
rendererPackageName: "react-test-renderer"
93629362
};
93639363
var internals$jscomp$inline_1250 = {
@@ -9388,7 +9388,7 @@ var internals$jscomp$inline_1250 = {
93889388
scheduleRoot: null,
93899389
setRefreshHandler: null,
93909390
getCurrentFiber: null,
9391-
reconcilerVersion: "19.0.0-native-fb-f3e09d6328-20240612"
9391+
reconcilerVersion: "19.0.0-native-fb-195d5bb99e-20240612"
93929392
};
93939393
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
93949394
var hook$jscomp$inline_1251 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<760b7e454fce1139a9e1db1033c564d0>>
10+
* @generated SignedSource<<f35fce92640f481c9eb6cc29117627aa>>
1111
*/
1212

1313
"use strict";
@@ -9979,7 +9979,7 @@ var devToolsConfig$jscomp$inline_1146 = {
99799979
throw Error("TestRenderer does not support findFiberByHostInstance()");
99809980
},
99819981
bundleType: 0,
9982-
version: "19.0.0-native-fb-f3e09d6328-20240612",
9982+
version: "19.0.0-native-fb-195d5bb99e-20240612",
99839983
rendererPackageName: "react-test-renderer"
99849984
};
99859985
(function (internals) {
@@ -10023,7 +10023,7 @@ var devToolsConfig$jscomp$inline_1146 = {
1002310023
scheduleRoot: null,
1002410024
setRefreshHandler: null,
1002510025
getCurrentFiber: null,
10026-
reconcilerVersion: "19.0.0-native-fb-f3e09d6328-20240612"
10026+
reconcilerVersion: "19.0.0-native-fb-195d5bb99e-20240612"
1002710027
});
1002810028
exports._Scheduler = Scheduler;
1002910029
exports.act = act;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<0740f9b2511c65b3833e96c3234356a1>>
10+
* @generated SignedSource<<d7ecd32a61474d852e2d40cc1ec28c08>>
1111
*/
1212

1313
"use strict";
@@ -1741,7 +1741,7 @@ __DEV__ &&
17411741
exports.useTransition = function () {
17421742
return resolveDispatcher().useTransition();
17431743
};
1744-
exports.version = "19.0.0-native-fb-f3e09d6328-20240612";
1744+
exports.version = "19.0.0-native-fb-195d5bb99e-20240612";
17451745
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
17461746
"function" ===
17471747
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<2e88b63b2f31fc9ad1d411ca231c9c65>>
10+
* @generated SignedSource<<5a4093ad1666047336503aabe558d5a1>>
1111
*/
1212

1313
"use strict";
@@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.0.0-native-fb-f3e09d6328-20240612";
607+
exports.version = "19.0.0-native-fb-195d5bb99e-20240612";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a5fef014bdf16dfd180291ec0e9561a1>>
10+
* @generated SignedSource<<31516b8c299906006f335595e835e19c>>
1111
*/
1212

1313
"use strict";
@@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
608608
exports.useTransition = function () {
609609
return ReactSharedInternals.H.useTransition();
610610
};
611-
exports.version = "19.0.0-native-fb-f3e09d6328-20240612";
611+
exports.version = "19.0.0-native-fb-195d5bb99e-20240612";
612612
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
613613
"function" ===
614614
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f3e09d6328eb0eca53d8dbc19ea6f8f4aa43db25
1+
195d5bb99e366889f0905779a0f9432d1624f999

0 commit comments

Comments
 (0)