MCPcopy
hub / github.com/dai-shi/react-tracked / useSelector

Function useSelector

src/createContainer.ts:73–89  ·  view source on GitHub ↗
(selector: (state: State) => Selected)

Source from the content-addressed store, hash-verified

71 };
72
73 const useSelector = <Selected>(selector: (state: State) => Selected) => {
74 if (hasGlobalProcess && process.env.NODE_ENV !== 'production') {
75 const selectorOrig = selector;
76 selector = (state: State) => {
77 if (state === undefined) {
78 throw new Error('Please use <Provider>');
79 }
80 return selectorOrig(state);
81 };
82 }
83 const selected = useContextSelector(
84 StateContext as Context<State>,
85 selector,
86 );
87 useDebugValue(selected);
88 return selected;
89 };
90
91 const useTrackedState = createTrackedSelector(useSelector);
92

Callers 3

useTrackedSelectorFunction · 0.85
CounterFunction · 0.85
PersonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…