MCPcopy
hub / github.com/facebook/react / popProvider

Function popProvider

packages/react-server/src/ReactFizzNewContext.js:230–280  ·  view source on GitHub ↗
(context: ReactContext<T>)

Source from the content-addressed store, hash-verified

228}
229
230export function popProvider<T>(context: ReactContext<T>): ContextSnapshot {
231 const prevSnapshot = currentActiveSnapshot;
232
233 if (prevSnapshot === null) {
234 throw new Error(
235 'Tried to pop a Context at the root of the app. This is a bug in React.',
236 );
237 }
238
239 if (__DEV__) {
240 if (prevSnapshot.context !== context) {
241 console.error(
242 'The parent context is not the expected context. This is probably a bug in React.',
243 );
244 }
245 }
246 if (isPrimaryRenderer) {
247 const value = prevSnapshot.parentValue;
248 prevSnapshot.context._currentValue = value;
249 if (__DEV__) {
250 if (
251 context._currentRenderer !== undefined &&
252 context._currentRenderer !== null &&
253 context._currentRenderer !== rendererSigil
254 ) {
255 console.error(
256 'Detected multiple renderers concurrently rendering the ' +
257 'same context provider. This is currently unsupported.',
258 );
259 }
260 context._currentRenderer = rendererSigil;
261 }
262 } else {
263 const value = prevSnapshot.parentValue;
264 prevSnapshot.context._currentValue2 = value;
265 if (__DEV__) {
266 if (
267 context._currentRenderer2 !== undefined &&
268 context._currentRenderer2 !== null &&
269 context._currentRenderer2 !== rendererSigil
270 ) {
271 console.error(
272 'Detected multiple renderers concurrently rendering the ' +
273 'same context provider. This is currently unsupported.',
274 );
275 }
276 context._currentRenderer2 = rendererSigil;
277 }
278 }
279 return (currentActiveSnapshot = prevSnapshot.parent);
280}
281
282export function getActiveContext(): ContextSnapshot {
283 return currentActiveSnapshot;

Callers 1

renderContextProviderFunction · 0.90

Calls 1

errorMethod · 0.65

Tested by

no test coverage detected