Skip to content

Commit f494e17

Browse files
committed
Fixed DEV mode issue with synchronously caused event (i.e. by accessed ref) of the same type within a handler calling an original handler too (fixes facebook#8559)
1 parent 3def431 commit f494e17

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Diff for: src/renderers/shared/utils/ReactErrorUtils.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ if (__DEV__) {
6262
* To help development we can get better devtools integration by simulating a
6363
* real browser event.
6464
*/
65+
var once = (fn) => {
66+
var result;
67+
return (...args) => {
68+
if (!result) {
69+
result = fn(...args);
70+
}
71+
return result;
72+
};
73+
};
6574
if (typeof window !== 'undefined' &&
6675
typeof window.dispatchEvent === 'function' &&
6776
typeof document !== 'undefined' &&
@@ -72,9 +81,7 @@ if (__DEV__) {
7281
func: (a: A) => void,
7382
a: A,
7483
): void {
75-
var boundFunc = function() {
76-
func(a);
77-
};
84+
var boundFunc = once(() => func(a));
7885
var evtType = `react-${name}`;
7986
fakeNode.addEventListener(evtType, boundFunc, false);
8087
var evt = document.createEvent('Event');

0 commit comments

Comments
 (0)