[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
This commit is contained in:
Sathya Gunsasekaran
2024-04-12 15:32:12 +01:00
parent d2018c51e1
commit 441024318c
@@ -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];
}