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

Function useContext

packages/react/src/ReactHooks.js:53–64  ·  view source on GitHub ↗
(Context: ReactContext<T>)

Source from the content-addressed store, hash-verified

51}
52
53export function useContext<T>(Context: ReactContext<T>): T {
54 const dispatcher = resolveDispatcher();
55 if (__DEV__) {
56 if (Context.$$typeof === REACT_CONSUMER_TYPE) {
57 console.error(
58 'Calling useContext(Context.Consumer) is not supported and will cause bugs. ' +
59 'Did you mean to call useContext(Context) instead?',
60 );
61 }
62 }
63 return dispatcher.useContext(Context);
64}
65
66export function useState<S>(
67 initialState: (() => S) | S,

Callers 11

ComponentFunction · 0.90
ComponentFunction · 0.90
ComponentFunction · 0.90
ComponentFunction · 0.90
Page2Function · 0.90
ThemeToggleButtonFunction · 0.90
LoadingIndicatorFunction · 0.90
useDataFunction · 0.90
AboutPageFunction · 0.90
HomePageFunction · 0.90
lazyLegacyRoot.jsFile · 0.90

Calls 2

resolveDispatcherFunction · 0.70
errorMethod · 0.65

Tested by 4

ComponentFunction · 0.72
ComponentFunction · 0.72
ComponentFunction · 0.72
ComponentFunction · 0.72