Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import type {SchedulingEvent} from 'react-devtools-timeline/src/types';
import type {ReactFunctionLocation} from 'shared/ReactTypes';

import * as React from 'react';
import Button from '../Button';
Expand All @@ -27,6 +28,28 @@ import styles from './SidebarEventInfo.css';

export type Props = {};

type FunctionLocationProps = {
location: ReactFunctionLocation,
displayName: string,
};
function FunctionLocation({location, displayName}: FunctionLocationProps) {
// TODO: We should support symbolication here as well, but
// symbolicating the whole stack can be expensive
const [canViewSource, viewSource] = useOpenResource(location, null);
return (
<li>
<Button
className={
canViewSource ? styles.ClickableSource : styles.UnclickableSource
}
disabled={!canViewSource}
onClick={viewSource}>
{displayName}
</Button>
</li>
);
}

type SchedulingEventProps = {
eventInfo: SchedulingEvent,
};
Expand Down Expand Up @@ -74,25 +97,12 @@ function SchedulingEventInfo({eventInfo}: SchedulingEventProps) {
);
}

// TODO: We should support symbolication here as well, but
// symbolicating the whole stack can be expensive
const [canViewSource, viewSource] = useOpenResource(
location,
null,
);
return (
<li key={index}>
<Button
className={
canViewSource
? styles.ClickableSource
: styles.UnclickableSource
}
disabled={!canViewSource}
onClick={viewSource}>
{displayName}
</Button>
</li>
<FunctionLocation
key={index}
displayName={displayName}
location={location}
/>
);
},
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,6 @@ function SuspenseTimelineInput() {
const min = 0;
const max = timeline.length > 0 ? timeline.length - 1 : 0;

if (rootID === null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These early returns will probably go away. This fixes the crashes in the meantime.

return (
<div className={styles.SuspenseTimelineInput}>No root selected.</div>
);
}

if (!store.supportsTogglingSuspense(rootID)) {
return (
<div className={styles.SuspenseTimelineInput}>
Can't step through Suspense in production apps.
</div>
);
}

if (timeline.length === 0) {
return (
<div className={styles.SuspenseTimelineInput}>
Root contains no Suspense nodes.
</div>
);
}

function switchSuspenseNode(nextTimelineIndex: number) {
const nextSelectedSuspenseID = timeline[nextTimelineIndex];
highlightHostInstance(nextSelectedSuspenseID);
Expand Down Expand Up @@ -175,6 +153,28 @@ function SuspenseTimelineInput() {
};
}, [playing]);

if (rootID === null) {
return (
<div className={styles.SuspenseTimelineInput}>No root selected.</div>
);
}

if (!store.supportsTogglingSuspense(rootID)) {
return (
<div className={styles.SuspenseTimelineInput}>
Can't step through Suspense in production apps.
</div>
);
}

if (timeline.length === 0) {
return (
<div className={styles.SuspenseTimelineInput}>
Root contains no Suspense nodes.
</div>
);
}

return (
<>
<Button
Expand Down
Loading