MCPcopy Index your code
hub / github.com/react/react / checkForUpdates

Function checkForUpdates

packages/react-devtools-shared/src/devtools/views/hooks.js:312–332  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

310 let didUnsubscribe = false;
311
312 const checkForUpdates = () => {
313 if (didUnsubscribe) {
314 return;
315 }
316
317 setState(prevState => {
318 if (
319 prevState.getCurrentValue !== getCurrentValue ||
320 prevState.subscribe !== subscribe
321 ) {
322 return prevState;
323 }
324
325 const value = getCurrentValue();
326 if (prevState.value === value) {
327 return prevState;
328 }
329
330 return {...prevState, value};
331 });
332 };
333 const unsubscribe = subscribe(checkForUpdates);
334
335 checkForUpdates();

Callers 1

useSubscriptionFunction · 0.85

Calls 1

setStateFunction · 0.50

Tested by

no test coverage detected