You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Devtools does not correctly identify context change for functional component #22737
The profiler says the component rendered because the parent component rendered. This is incorrect, as the parent component is a MemoComponent that did in fact not render.
The expected behavior
The component actually rendered because its context was changed. When digging into the devtools code, we are checking the memoizedValue value on the context, which doesn't seem to exist.
while (prevContext && nextContext) {
if (!is(prevContext.memoizedValue, nextContext.memoizedValue)) {
return true;
}
prevContext = prevContext.next;
nextContext = nextContext.next;
}
I couldn't find the actual value on the context property; or in the memoizedState.
PR #22746 fixes this issue for newer versions of React (e.g. 18 alpha) but older versions will remain broken because there's not a good way to read the most recent context value for a Fiber after render has completed. This is because React maintains a stack of context values during render, but by the time DevTools is called– render has finished and the stack is empty.
Activity
KamranAsif commentedon Nov 10, 2021
Fixed codesandbox link
bvaughn commentedon Nov 11, 2021
PR #22746 fixes this issue for newer versions of React (e.g. 18 alpha) but older versions will remain broken because there's not a good way to read the most recent context value for a Fiber after render has completed. This is because React maintains a stack of context values during render, but by the time DevTools is called– render has finished and the stack is empty.