Skip to content

Commit

Permalink
feat: 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 6c9c87a commit 59639c6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/components/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,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 59639c6

Please sign in to comment.