From 441024318c2286f75979292577ef7e25fbb2cffb Mon Sep 17 00:00:00 2001 From: Sathya Gunsasekaran Date: Fri, 12 Apr 2024 15:32:12 +0100 Subject: [PATCH] [polyfill] Add sentinel to array To make the polyfill work well with devtools, we add this sentinel. Devtools will look for this sentinel before adding the Forget badge. ghstack-source-id: d246040f67da48fa46f818753c8bf26dff56f390 Pull Request resolved: https://github.com/facebook/react-forget/pull/2847 --- compiler/packages/react-forget-runtime/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/packages/react-forget-runtime/src/index.ts b/compiler/packages/react-forget-runtime/src/index.ts index 8c9658e6fe..415b86aa15 100644 --- a/compiler/packages/react-forget-runtime/src/index.ts +++ b/compiler/packages/react-forget-runtime/src/index.ts @@ -28,6 +28,10 @@ export function unstable_useMemoCache(size: number) { for (let ii = 0; ii < size; ii++) { $[ii] = $empty; } + // This symbol is added to tell the react devtools that this array is from + // useMemoCache. + // @ts-ignore + $[$empty] = true; return $; })[0]; }