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

Function hydrateHelper

packages/react-devtools-shared/src/backendAPI.js:329–355  ·  view source on GitHub ↗
(
  dehydratedData: DehydratedData | null,
  path: ?InspectedElementPath,
)

Source from the content-addressed store, hash-verified

327}
328
329export function hydrateHelper(
330 dehydratedData: DehydratedData | null,
331 path: ?InspectedElementPath,
332): Object | null {
333 if (dehydratedData !== null) {
334 const {cleaned, data, unserializable} = dehydratedData;
335
336 if (path) {
337 const {length} = path;
338 if (length > 0) {
339 // Hydration helper requires full paths, but inspection dehydrates with relative paths.
340 // In that event it's important that we adjust the "cleaned" paths to match.
341 return hydrate(
342 data,
343 cleaned.map(cleanedPath => cleanedPath.slice(length)),
344 unserializable.map(unserializablePath =>
345 unserializablePath.slice(length),
346 ),
347 );
348 }
349 }
350
351 return hydrate(data, cleaned, unserializable);
352 } else {
353 return null;
354 }
355}

Callers 3

inspectElementFunction · 0.90

Calls 2

hydrateFunction · 0.90
mapMethod · 0.65

Tested by

no test coverage detected