@samitouri / QOS-React / commits / 4d686a2da1

Performance: avoid triggering map deopt in V8 (#28569)

The shape of the objects changed by this PR are both created in 2 locations with 2 different shapes, which most JS engines won't like. I've noticed this in particular in V8 while benchmarking production code. https://github.com/facebook/react/blob/1293047d6063f3508af15e68cca916660ded791e/packages/react-reconciler/src/ReactFiberCacheComponent.js#L66-L77 https://github.com/facebook/react/blob/1293047d6063f3508af15e68cca916660ded791e/packages/react-reconciler/src/ReactFiberHostContext.js#L47-L54 https://github.com/facebook/react/blob/1293047d6063f3508af15e68cca916660ded791e/packages/react-reconciler/src/ReactFiberHooks.js#L3530-L3531 https://github.com/facebook/react/blob/1293047d6063f3508af15e68cca916660ded791e/packages/react-reconciler/src/ReactFiberHooks.js#L3492-L3493

Rom Grk committed Mar 18, 2024 at 11:54 UTC 4d686a2da138cad9e76c7de9feadd81ca2aa29e5
2 files changed +3 -3
packages/react-reconciler/src/ReactFiberHooks.js
+1 -1
@@ -3489,8 +3489,8 @@ export const ContextOnlyDispatcher: Dispatcher = {
3489 useContext: throwInvalidHookError,
3490 useEffect: throwInvalidHookError,
3491 useImperativeHandle: throwInvalidHookError,
3492 - useInsertionEffect: throwInvalidHookError,
3492 useLayoutEffect: throwInvalidHookError,
3493 + useInsertionEffect: throwInvalidHookError,
3494 useMemo: throwInvalidHookError,
3495 useReducer: throwInvalidHookError,
3496 useRef: throwInvalidHookError,
packages/react-reconciler/src/ReactFiberHostContext.js
+2 -2
@@ -46,11 +46,11 @@ const hostTransitionProviderCursor: StackCursor<Fiber | null> =
46 // inside useHostTransitionStatus.
47 export const HostTransitionContext: ReactContext<TransitionStatus | null> = {
48 $$typeof: REACT_CONTEXT_TYPE,
49 + Provider: (null: any),
50 + Consumer: (null: any),
51 _currentValue: null,
52 _currentValue2: null,
53 _threadCount: 0,
52 - Provider: (null: any),
53 - Consumer: (null: any),
54 };
55
56 function requiredContext<Value>(c: Value | null): Value {