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 f1c26c2
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 older React versions.
// Current owner and dispatcher used to share the same ref.
// PR #14548 split them out to better support "react-debug-tools".
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 f1c26c2

Please sign in to comment.