[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
Sathya Gunsasekaran committed
Apr 12, 2024 at 15:32 UTC
441024318c2286f75979292577ef7e25fbb2cffb
1 file changed
+4
compiler/packages/react-forget-runtime/src/index.ts
+4
@@ -28,6 +28,10 @@ export function unstable_useMemoCache(size: number) {
28
for (let ii = 0; ii < size; ii++) {
29
$[ii] = $empty;
30
}
31
+ // This symbol is added to tell the react devtools that this array is from
32
+ // useMemoCache.
33
+ // @ts-ignore
34
+ $[$empty] = true;
35
return $;
36
})[0];
37
}