Skip to content

Commit

Permalink
Move sentinel var into function body
Browse files Browse the repository at this point in the history
We don't need this symbol allocated unless we're handling a
useMemoCache call
  • Loading branch information
poteto committed Apr 25, 2023
1 parent 3124fcf commit de0445d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import {
ForwardRef,
} from 'react-reconciler/src/ReactWorkTags';

const MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');

type CurrentDispatcherRef = typeof ReactSharedInternals.ReactCurrentDispatcher;

// Used to track hooks called during a render
Expand Down Expand Up @@ -367,6 +365,7 @@ function useMemoCache(size: number): Array<any> {

let data = memoCache.data[memoCache.index];
if (data === undefined) {
const MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
data = new Array(size);
for (let i = 0; i < size; i++) {
data[i] = MEMO_CACHE_SENTINEL;
Expand Down

0 comments on commit de0445d

Please sign in to comment.