Remove unstable_read() in favor of direct dispatcher call#13861
Remove unstable_read() in favor of direct dispatcher call#13861gaearon merged 2 commits intofacebook:masterfrom
Conversation
|
React: size: -1.2%, gzip: -0.6% Details of bundled changes.Comparing: 21a79a1...35cf54c react
scheduler
Generated by 🚫 dangerJS |
|
This is sad. |
|
I mean, you can still use it in a library. Your translation library could literally do the same thing that const ReactCurrentOwner = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
function readContext(Context) {
const dispatcher = ReactCurrentOwner.currentDispatcher;
return dispatcher.readContext(Context);
} |
|
Great! Thank you. |
|
Uh... that seems really icky. Why are you effectively encouraging digging around in React's internals? What's the reasoning for removing this? |
|
|
…3861) * Remove unstable_read() in favor of direct dispatcher call * This no longer throws immediately
…3861) * Remove unstable_read() in favor of direct dispatcher call * This no longer throws immediately
|
So I'm starting to poke around at potential ways to re-revamp
|
|
Or |
|
Don’t have a good answer for you that’s guaranteed to work earlier. |
|
Yeah, I know. That's why I'm diving off the deep end and experimenting with a hooks-based approach first.
|
It's an advanced feature that shouldn't be used by application code directly. For example classes are supposed to use
contextType(reactjs/react.dev#1265) instead.So we want to hide it a bit deeper. This makes it only available via direct dispatcher read. Also removes an extra runtime check.
Libraries can still use it by calling the dispatcher directly.