Skip to content

Commit

Permalink
Support Replay RDT fork
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Oct 20, 2023
1 parent 6732942 commit 3a87e14
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3698,6 +3698,29 @@ export function attach(
// This will enable us to send patches without re-inspecting if hydrated paths are requested.
// (Reducing how often we shallow-render is a better DX for function components that use hooks.)
const cleanedInspectedElement = {...mostRecentlyInspectedElement};

// [FE-1885] Note that the internal.registerPlainObject API is only available for newer Replay Chromium builds.
const getObjectId = __RECORD_REPLAY_ARGUMENTS__.internal
? __RECORD_REPLAY_ARGUMENTS__.internal.registerPlainObject
: () => null;

// [FE-1885] React DevTools uses a bespoke format for inspecting props/state/hooks data;
// Replay's React DevTools fork uses the Replay Inspector (and the Replay object preview format)
// For the time being, the backend needs to support both,
// but eventually we can remove a lot of this info from the inspected element payload.
cleanedInspectedElement.contextObjectId = cleanedInspectedElement.context
? getObjectId(cleanedInspectedElement.context)
: null;
cleanedInspectedElement.hooksObjectId = cleanedInspectedElement.hooks
? getObjectId(cleanedInspectedElement.hooks)
: null;
cleanedInspectedElement.propsObjectId = cleanedInspectedElement.props
? getObjectId(cleanedInspectedElement.props)
: null;
cleanedInspectedElement.stateObjectId = cleanedInspectedElement.state
? getObjectId(cleanedInspectedElement.state)
: null;

// $FlowFixMe[prop-missing] found when upgrading Flow
cleanedInspectedElement.context = cleanForBridge(
cleanedInspectedElement.context,
Expand Down

0 comments on commit 3a87e14

Please sign in to comment.