MCPcopy Create free account
hub / github.com/microsoft/SandDance / useContext

Function useContext

docs/external/js/react.development.js:1558–1580  ·  view source on GitHub ↗
(Context, unstable_observedBits)

Source from the content-addressed store, hash-verified

1556 }
1557
1558 function useContext(Context, unstable_observedBits) {
1559 var dispatcher = resolveDispatcher();
1560
1561 {
1562 if (unstable_observedBits !== undefined) {
1563 error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '');
1564 } // TODO: add a more generic warning for invalid values.
1565
1566
1567 if (Context._context !== undefined) {
1568 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
1569 // and nobody should be using this in existing code.
1570
1571 if (realContext.Consumer === Context) {
1572 error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
1573 } else if (realContext.Provider === Context) {
1574 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
1575 }
1576 }
1577 }
1578
1579 return dispatcher.useContext(Context, unstable_observedBits);
1580 }
1581 function useState(initialState) {
1582 var dispatcher = resolveDispatcher();
1583 return dispatcher.useState(initialState);

Callers

nothing calls this directly

Calls 2

resolveDispatcherFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected