Skip to content

Commit 602b567

Browse files
committed
[Devtools] Look for a ReactMemoCacheSentinel on state
The polyfill doesn't have access to the fiber, and it simply uses state, which makes it not work with the devtools. With this PR, devtools will look for this special sentinel on very first hook's state for this sentinel and display the Forget badge if present. The poylfill will add this sentinel to it's state (the cache array).
1 parent d012a32 commit 602b567

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import {
8686
STRICT_MODE_SYMBOL_STRING,
8787
PROFILER_NUMBER,
8888
PROFILER_SYMBOL_STRING,
89+
REACT_MEMO_CACHE_SENTINEL,
8990
SCOPE_NUMBER,
9091
SCOPE_SYMBOL_STRING,
9192
FORWARD_REF_NUMBER,
@@ -475,7 +476,11 @@ export function getInternalReactConstants(version: string): {
475476

476477
let resolvedContext: any = null;
477478
// $FlowFixMe[incompatible-type] fiber.updateQueue is mixed
478-
if (!shouldSkipForgetCheck && fiber.updateQueue?.memoCache != null) {
479+
if (
480+
!shouldSkipForgetCheck &&
481+
(fiber.updateQueue?.memoCache != null ||
482+
fiber.memoizedState?.memoizedState?.[REACT_MEMO_CACHE_SENTINEL])
483+
) {
479484
const displayNameWithoutForgetWrapper = getDisplayNameForFiber(
480485
fiber,
481486
true,

0 commit comments

Comments
 (0)