Skip to content

Commit

Permalink
prevent unnecessary re-renders of main layout
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Nov 3, 2024
1 parent 63ba7e4 commit d6bad42
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions ui/src/components/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ export function RootLayout({

function HeaderSelectorFixAppLayout(props: AppLayoutProps) {
const { headerSelector, ...appLayoutProps } = props;
const [key, setKey] = useState(`a${Date.now()}-${Math.random()}`);

useEffect(() => {
setKey(`a${Date.now()}-${Math.random()}`);
}, [headerSelector]);
const key = useMemo(() => `a${Date.now()}-${Math.random()}`, [headerSelector]);

return (
<AppLayout key={key} headerSelector={headerSelector} {...appLayoutProps} />
Expand Down

0 comments on commit d6bad42

Please sign in to comment.