From f1c26c2bf6bf02b1f820c61c28b49e8d8bac5980 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 6 Feb 2019 15:32:27 +0000 Subject: [PATCH] Added possible backwards compatibility fix for ReactCurrentDispatcher with older react package versions --- packages/shared/ReactSharedInternals.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/shared/ReactSharedInternals.js b/packages/shared/ReactSharedInternals.js index d8aea57f6bb3a..40f2a53f8539e 100644 --- a/packages/shared/ReactSharedInternals.js +++ b/packages/shared/ReactSharedInternals.js @@ -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;