Skip to content

Commit

Permalink
feat: ScrollRestoration RootLayout으로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
Legitgoons committed May 29, 2024
1 parent 32c52dd commit 3700676
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
7 changes: 6 additions & 1 deletion src/app/layout/RootLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IPhoneLayout } from 'react-iphone-layout';
import 'react-iphone-layout/dist/ReactIPhoneLayout.css';
import { Outlet } from 'react-router-dom';
import { Outlet, ScrollRestoration } from 'react-router-dom';

import './RootLayout.scss';

Expand All @@ -15,6 +15,11 @@ export const RootLayout = () => {
<div className='wrap'>
<Outlet />
</div>
<ScrollRestoration
getKey={(location) => {
return location.pathname;
}}
/>
</IPhoneLayout>
);
};
17 changes: 2 additions & 15 deletions src/app/routers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
createBrowserRouter,
RouteObject,
ScrollRestoration,
} from 'react-router-dom';
import { createBrowserRouter, RouteObject } from 'react-router-dom';

import { FeedMainPage } from '@/pages/feed-main';
import { ProfileMainPage } from '@/pages/profile';
Expand All @@ -12,16 +8,7 @@ import { RootLayout } from '../layout';
const root: RouteObject[] = [
{
path: '/',
element: (
<>
<RootLayout />
<ScrollRestoration
getKey={(location) => {
return location.pathname;
}}
/>
</>
),
element: <RootLayout />,
children: [
{ index: true, element: <FeedMainPage /> },
{ path: 'users/:userId', element: <ProfileMainPage /> },
Expand Down

0 comments on commit 3700676

Please sign in to comment.