| 211 | } |
| 212 | |
| 213 | function pushContextProvider(workInProgress: Fiber): boolean { |
| 214 | if (disableLegacyContext) { |
| 215 | return false; |
| 216 | } else { |
| 217 | const instance = workInProgress.stateNode; |
| 218 | // We push the context as early as possible to ensure stack integrity. |
| 219 | // If the instance does not exist yet, we will push null at first, |
| 220 | // and replace it on the stack later when invalidating the context. |
| 221 | const memoizedMergedChildContext = |
| 222 | (instance && instance.__reactInternalMemoizedMergedChildContext) || |
| 223 | emptyContextObject; |
| 224 | |
| 225 | // Remember the parent context so we can merge with it later. |
| 226 | // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. |
| 227 | previousContext = contextStackCursor.current; |
| 228 | push(contextStackCursor, memoizedMergedChildContext, workInProgress); |
| 229 | push( |
| 230 | didPerformWorkStackCursor, |
| 231 | didPerformWorkStackCursor.current, |
| 232 | workInProgress, |
| 233 | ); |
| 234 | |
| 235 | return true; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | function invalidateContextProvider( |
| 240 | workInProgress: Fiber, |