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

Function renderContextConsumer

packages/react-server/src/ReactFizzServer.js:2729–2756  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  keyPath: KeyNode,
  context: ReactContext<any>,
  props: Object,
)

Source from the content-addressed store, hash-verified

2727}
2728
2729function renderContextConsumer(
2730 request: Request,
2731 task: Task,
2732 keyPath: KeyNode,
2733 context: ReactContext<any>,
2734 props: Object,
2735): void {
2736 const render = props.children;
2737
2738 if (__DEV__) {
2739 if (typeof render !== 'function') {
2740 console.error(
2741 'A context consumer was rendered with multiple children, or a child ' +
2742 "that isn't a function. A context consumer expects a single child " +
2743 'that is a function. If you did pass a function, make sure there ' +
2744 'is no trailing or leading whitespace around it.',
2745 );
2746 }
2747 }
2748
2749 const newValue = readContext(context);
2750 const newChildren = render(newValue);
2751
2752 const prevKeyPath = task.keyPath;
2753 task.keyPath = keyPath;
2754 renderNodeDestructive(request, task, newChildren, -1);
2755 task.keyPath = prevKeyPath;
2756}
2757
2758function renderContextProvider(
2759 request: Request,

Callers 1

renderElementFunction · 0.85

Calls 4

readContextFunction · 0.90
renderNodeDestructiveFunction · 0.85
errorMethod · 0.65
renderFunction · 0.50

Tested by

no test coverage detected