Skip to content

Commit

Permalink
Added possible backwards compatibility fix for ReactCurrentDispatcher…
Browse files Browse the repository at this point in the history
… with older react package versions
  • Loading branch information
Brian Vaughn committed Feb 6, 2019
1 parent 0975ea3 commit 8ab0da5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/shared/ReactSharedInternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@ import React from 'react';
const ReactSharedInternals =
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

// Add fallabck for newer renderers running with older react package versions.
// Current owner and dispatcher used to share the same ref,
// but PR #14548 split them out to better support the react-debug-tools package.
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
const {ReactCurrentOwner} = ReactSharedInternals;
ReactSharedInternals.ReactCurrentDispatcher = {
get current() {
return ReactCurrentOwner.currentDispatcher;
},
set current(value) {
ReactCurrentOwner.currentDispatcher = value;
},
};
}

export default ReactSharedInternals;

0 comments on commit 8ab0da5

Please sign in to comment.