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

Function checkForUpdate

packages/react-devtools-shared/src/inspectedElementCache.js:171–208  ·  view source on GitHub ↗
({
  bridge,
  element,
  refresh,
  store,
}: {
  bridge: FrontendBridge,
  element: Element,
  refresh: RefreshFunction,
  store: Store,
})

Source from the content-addressed store, hash-verified

169 * This method will schedule an update if updated information is returned.
170 */
171export function checkForUpdate({
172 bridge,
173 element,
174 refresh,
175 store,
176}: {
177 bridge: FrontendBridge,
178 element: Element,
179 refresh: RefreshFunction,
180 store: Store,
181}): void | Promise<void> {
182 const {id} = element;
183 const rendererID = store.getRendererIDForElement(id);
184
185 if (rendererID == null) {
186 return;
187 }
188
189 return inspectElementMutableSource(
190 bridge,
191 element,
192 null,
193 rendererID,
194 true,
195 ).then(
196 ([inspectedElement, responseType]: [
197 InspectedElementFrontend,
198 InspectedElementResponseType,
199 ]) => {
200 if (responseType === 'full-data') {
201 startTransition(() => {
202 const [key, value] = createCacheSeed(element, inspectedElement);
203 refresh(key, value);
204 });
205 }
206 },
207 );
208}
209
210function createPromiseWhichResolvesInOneSecond() {
211 return new Promise(resolve => setTimeout(resolve, 1000));

Callers 1

pollFunction · 0.85

Calls 4

startTransitionFunction · 0.90
createCacheSeedFunction · 0.85
thenMethod · 0.65

Tested by

no test coverage detected