Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: devtools source field disappears after component remount #27297

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import type {ReactElement} from 'shared/ReactElementType';
import type {ReactElement, Source} from 'shared/ReactElementType';
import type {ReactFragment, ReactPortal, ReactScope} from 'shared/ReactTypes';
import type {Fiber} from './ReactInternalTypes';
import type {RootTag} from './ReactRootTags';
Expand Down Expand Up @@ -490,6 +490,7 @@ export function createFiberFromTypeAndProps(
type: any, // React$ElementType
key: null | string,
pendingProps: any,
source: null | Source,
owner: null | Fiber,
mode: TypeOfMode,
lanes: Lanes,
Expand Down Expand Up @@ -643,6 +644,7 @@ export function createFiberFromTypeAndProps(
fiber.lanes = lanes;

if (__DEV__) {
fiber._debugSource = source;
fiber._debugOwner = owner;
}

Expand All @@ -654,8 +656,10 @@ export function createFiberFromElement(
mode: TypeOfMode,
lanes: Lanes,
): Fiber {
let source = null;
let owner = null;
if (__DEV__) {
source = element._source;
owner = element._owner;
}
const type = element.type;
Expand All @@ -665,6 +669,7 @@ export function createFiberFromElement(
type,
key,
pendingProps,
source,
owner,
mode,
lanes,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ function updateMemoComponent(
Component.type,
null,
nextProps,
null,
workInProgress,
workInProgress.mode,
renderLanes,
Expand Down Expand Up @@ -4013,6 +4014,7 @@ function beginWork(
workInProgress.type,
workInProgress.key,
workInProgress.pendingProps,
workInProgress._debugSource || null,
workInProgress._debugOwner || null,
workInProgress.mode,
workInProgress.lanes,
Expand Down
1 change: 1 addition & 0 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,7 @@ function detachFiberAfterEffects(fiber: Fiber) {
fiber.stateNode = null;

if (__DEV__) {
fiber._debugSource = null;
fiber._debugOwner = null;
}

Expand Down