Skip to content

Commit

Permalink
fix: prevent LibraryLayout remount
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido authored and pomegranited committed Jan 16, 2025
1 parent 7aaa8f7 commit e92eeb6
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/library-authoring/LibraryLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Route,
Routes,
useParams,
useLocation,
} from 'react-router-dom';

import { ROUTES } from './routes';
Expand All @@ -23,12 +22,8 @@ const LibraryLayout = () => {
throw new Error('Error: route is missing libraryId.');
}

const location = useLocation();
const context = useCallback((childPage) => (
<LibraryProvider
/** We need to pass the pathname as key to the LibraryProvider to force a
* re-render when we navigate to a new path or page. */
key={location.pathname}
libraryId={libraryId}
/** The component picker modal to use. We need to pass it as a reference instead of
* directly importing it to avoid the import cycle:
Expand All @@ -44,7 +39,7 @@ const LibraryLayout = () => {
</>
</SidebarProvider>
</LibraryProvider>
), [location.pathname]);
), []);

return (
<Routes>
Expand Down

0 comments on commit e92eeb6

Please sign in to comment.