<ConnectedRouter history={history}>
...
<Outter>
<Container>
<Header />
<Switch>
<PublickRoute path="/" exact component={Intro} />
<PublickRoute path="/login" exact component={Login} />
<PublickRoute path="/signup" exact component={Signup} />
...
<NotFound />
</Switch>
<BottomNav />
</Container>
</Outter>
</ConnectedRouter>
);
}
const Container = styled.div`
width: 375px;
height: 100%;
padding-bottom: 60px;
position: relative;
background: #fff;
overflow-y: auto;
overflow-x: hidden;
::-webkit-scrollbar {
display: none;
}
`;
const Outter = styled.div`
position: fixed;
left: 60%;
transform: translate(-60%, 0);
height: 100vh;
background-size: cover;
background-repeat: no-repeat;
`;
이런식으로 PublicRoute 안에서 로그인체크를해서 로그인을 한 유저에게만 보여지도록 처리를해주고, Container에서 스크롤이 생기며, Outter라는 div를 하나더 만들어줬었다. Outter는 전체 뷰포트 높이를 잡아주고, 웹페이지로 볼때 위치를 지정해주는 역할을 하는데, 이것때문에 scrollTop이 먹지가 않았다. 생각해보니 이 함수는 뷰포트에서 스크롤이 생겼을 때 스크롤 위치를 조정해주는 건데, 우리는 그냥 한 컴포넌트안에서 스크롤을 만들고 그걸 올리려고 하니 당연히 올라가지 않았던 건데 그걸 몰랐다 ㅠ. 이제 알았으니 헤더랑 바텀을 각 페이지안에 넣고, scrollTop을 페이지마다 넣어주면 될 것같다.