Skip to content

Commit 8ab0da5

Browse files
author
Brian Vaughn
committed
Added possible backwards compatibility fix for ReactCurrentDispatcher with older react package versions
1 parent 0975ea3 commit 8ab0da5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/shared/ReactSharedInternals.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,19 @@ import React from 'react';
1010
const ReactSharedInternals =
1111
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1212

13+
// Add fallabck for newer renderers running with older react package versions.
14+
// Current owner and dispatcher used to share the same ref,
15+
// but PR #14548 split them out to better support the react-debug-tools package.
16+
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
17+
const {ReactCurrentOwner} = ReactSharedInternals;
18+
ReactSharedInternals.ReactCurrentDispatcher = {
19+
get current() {
20+
return ReactCurrentOwner.currentDispatcher;
21+
},
22+
set current(value) {
23+
ReactCurrentOwner.currentDispatcher = value;
24+
},
25+
};
26+
}
27+
1328
export default ReactSharedInternals;

0 commit comments

Comments
 (0)