Skip to content

Commit 11a486a

Browse files
committed
fix issues
1 parent 19918fd commit 11a486a

File tree

5 files changed

+46
-43
lines changed

5 files changed

+46
-43
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { memo } from "react"
12
import { useStyles } from "../styles/use-styles.js"
23

34
interface TabContentProps {
45
children: React.ReactNode
56
}
67

7-
export const TabContent = ({ children }: TabContentProps) => {
8+
export const TabContent = memo(({ children }: TabContentProps) => {
89
const { styles } = useStyles()
910
return <div className={styles.tabContent.container}>{children}</div>
10-
}
11+
})

packages/react-router-devtools/src/client/embedded-dev-tools.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import clsx from "clsx"
2-
import { useEffect, useState } from "react"
2+
import { memo, useEffect, useState } from "react"
33
import { RDTContextProvider } from "./context/RDTContext.js"
44
import { useFindRouteOutlets } from "./hooks/useReactTreeListeners.js"
55
import { useSetRouteBoundaries } from "./hooks/useSetRouteBoundaries.js"
@@ -16,7 +16,7 @@ export interface EmbeddedDevToolsProps extends ReactRouterDevtoolsProps {
1616
mainPanelClassName?: string
1717
className?: string
1818
}
19-
const Embedded = ({ mainPanelClassName, className }: EmbeddedDevToolsProps) => {
19+
const Embedded = memo(({ mainPanelClassName, className }: EmbeddedDevToolsProps) => {
2020
useTimelineHandler()
2121
useFindRouteOutlets()
2222
useSetRouteBoundaries()
@@ -44,7 +44,7 @@ const Embedded = ({ mainPanelClassName, className }: EmbeddedDevToolsProps) => {
4444
) : null}
4545
</div>
4646
)
47-
}
47+
})
4848

4949
let hydrating = true
5050

packages/react-router-devtools/src/client/layout/Tabs.tsx

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { memo } from "react"
12
import { useSettingsContext } from "../context/useRDTContext.js"
23
import { useHorizontalScroll } from "../hooks/useHorizontalScroll.js"
34
import { useTabs } from "../hooks/useTabs.js"
@@ -11,37 +12,39 @@ declare global {
1112
}
1213
}
1314

14-
const Tab = ({
15-
tab,
16-
activeTab,
17-
className,
18-
onClick,
19-
}: {
20-
tab: TabType
21-
activeTab?: string
22-
className?: string
23-
onClick?: () => void
24-
}) => {
25-
const { setSettings } = useSettingsContext()
26-
const { styles } = useStyles()
15+
const Tab = memo(
16+
({
17+
tab,
18+
activeTab,
19+
className,
20+
onClick,
21+
}: {
22+
tab: TabType
23+
activeTab?: string
24+
className?: string
25+
onClick?: () => void
26+
}) => {
27+
const { setSettings } = useSettingsContext()
28+
const { styles } = useStyles()
2729

28-
return (
29-
<button
30-
data-testid={tab.id}
31-
onClick={() => (onClick ? onClick() : setSettings({ activeTab: tab.id as TabsType }))}
32-
title={typeof tab.name === "string" ? tab.name : undefined}
33-
type="button"
34-
className={cx(
35-
"group",
36-
styles.layout.tabs.tab,
37-
activeTab !== tab.id && styles.layout.tabs.tabInactive,
38-
activeTab === tab.id && styles.layout.tabs.tabActive
39-
)}
40-
>
41-
<div className={cx(className, styles.layout.tabs.tabIcon)}>{tab.icon}</div>
42-
</button>
43-
)
44-
}
30+
return (
31+
<button
32+
data-testid={tab.id}
33+
onClick={() => (onClick ? onClick() : setSettings({ activeTab: tab.id as TabsType }))}
34+
title={typeof tab.name === "string" ? tab.name : undefined}
35+
type="button"
36+
className={cx(
37+
"group",
38+
styles.layout.tabs.tab,
39+
activeTab !== tab.id && styles.layout.tabs.tabInactive,
40+
activeTab === tab.id && styles.layout.tabs.tabActive
41+
)}
42+
>
43+
<div className={cx(className, styles.layout.tabs.tabIcon)}>{tab.icon}</div>
44+
</button>
45+
)
46+
}
47+
)
4548

4649
const Tabs = () => {
4750
const { settings } = useSettingsContext()

packages/react-router-devtools/src/client/tabs/RoutesTab.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const RoutesTab = () => {
5050
}
5151

5252
// Add root from manifest
53-
routeObject.root = window.__reactRouterManifest?.routes?.root
53+
routeObject.root = { ...window.__reactRouterManifest?.routes?.root }
5454

5555
// Update tree view routes with merged data
5656
setTreeRoutes(createRouteTree(routeObject))
@@ -63,9 +63,7 @@ const RoutesTab = () => {
6363
// Request routes info from the server AFTER listener is set up
6464
eventClient.emit("routes-tab-mounted", {})
6565

66-
return () => {
67-
unsubscribe()
68-
}
66+
return unsubscribe
6967
}, [])
7068
return (
7169
<div className={styles.routesTab.wrapper}>

packages/react-router-devtools/src/client/tabs/TimelineTab.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { memo } from "react"
12
import { TabContent } from "../components/TabContent.js"
23
import { TabHeader } from "../components/TabHeader.js"
34
import { type TAG_COLORS, Tag } from "../components/Tag.js"
@@ -17,7 +18,7 @@ const Translations: Record<TimelineEvent["type"], string> = {
1718
FETCHER_RESPONSE: "Fetcher action response",
1819
}
1920

20-
const RedirectEventComponent = (event: RedirectEvent) => {
21+
const RedirectEventComponent = memo((event: RedirectEvent) => {
2122
const { styles } = useStyles()
2223
return (
2324
<div className={styles.timelineTab.eventContainer}>
@@ -31,9 +32,9 @@ const RedirectEventComponent = (event: RedirectEvent) => {
3132
)}
3233
</div>
3334
)
34-
}
35+
})
3536

36-
const FormEventComponent = (event: FormEvent) => {
37+
const FormEventComponent = memo((event: FormEvent) => {
3738
const { styles } = useStyles()
3839
const isRedirect = event.type === "ACTION_REDIRECT"
3940
const responseData = event.responseData
@@ -73,7 +74,7 @@ const FormEventComponent = (event: FormEvent) => {
7374
</div>
7475
</div>
7576
)
76-
}
77+
})
7778

7879
export const METHOD_COLORS: Record<string, keyof typeof TAG_COLORS> = {
7980
GET: "GREEN",

0 commit comments

Comments
 (0)