Prevent deopts from modifying exports object in stable builds (#14309)
This commit is contained in:
parent
0c7189d923
commit
7475120ce7
|
@ -770,6 +770,7 @@ const ReactDOM: Object = {
|
|||
|
||||
flushSync: flushSync,
|
||||
|
||||
unstable_createRoot: createRoot,
|
||||
unstable_flushControlled: flushControlled,
|
||||
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
|
||||
|
@ -810,8 +811,7 @@ function createRoot(container: DOMContainer, options?: RootOptions): ReactRoot {
|
|||
|
||||
if (enableStableConcurrentModeAPIs) {
|
||||
ReactDOM.createRoot = createRoot;
|
||||
} else {
|
||||
ReactDOM.unstable_createRoot = createRoot;
|
||||
ReactDOM.unstable_createRoot = undefined;
|
||||
}
|
||||
|
||||
const foundDevTools = injectIntoDevTools({
|
||||
|
|
|
@ -77,15 +77,22 @@ const React = {
|
|||
|
||||
version: ReactVersion,
|
||||
|
||||
unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
|
||||
unstable_Profiler: REACT_PROFILER_TYPE,
|
||||
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals,
|
||||
};
|
||||
|
||||
// Note: some APIs are added with feature flags.
|
||||
// Make sure that stable builds for open source
|
||||
// don't modify the React object to avoid deopts.
|
||||
// Also let's not expose their names in stable builds.
|
||||
|
||||
if (enableStableConcurrentModeAPIs) {
|
||||
React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
||||
React.Profiler = REACT_PROFILER_TYPE;
|
||||
} else {
|
||||
React.unstable_ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
||||
React.unstable_Profiler = REACT_PROFILER_TYPE;
|
||||
React.unstable_ConcurrentMode = undefined;
|
||||
React.unstable_Profiler = undefined;
|
||||
}
|
||||
|
||||
if (enableHooks) {
|
||||
|
|
Loading…
Reference in New Issue