Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Replaced current owner forward with current:null
  • Loading branch information
Brian Vaughn committed Feb 6, 2019
commit 6e638c9667e2e19fa310ff2927255c449c6a88ce
10 changes: 2 additions & 8 deletions packages/shared/ReactSharedInternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ import React from 'react';
const ReactSharedInternals =
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

// Add fallback for newer renderers running with older react package versions.
// Prevent newer renderers from RTE when used 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 = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this just be {current: null}? Why does it need to forward to the owner object?

Copy link
Contributor Author

@bvaughn bvaughn Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I wasn't convinced that no 16.8+ renderer would ever have a valid use case for accessing current dispatcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. react-cache uses it

get current() {
return ReactCurrentOwner.currentDispatcher;
},
set current(value) {
ReactCurrentOwner.currentDispatcher = value;
},
current: null,
};
}

Expand Down