1- import React from 'react' ;
1+ import React , { useEffect } from 'react' ;
22import styled from 'styled-components' ;
33import VelogResponsive from '../../components/velog/VelogResponsive' ;
44import UserProfileContainer from '../../containers/velog/UserProfileContainer' ;
@@ -9,20 +9,34 @@ import SeriesTab from './tabs/SeriesTab';
99import AboutTab from './tabs/AboutTab' ;
1010import palette from '../../lib/styles/palette' ;
1111import media from '../../lib/styles/media' ;
12+ import UserTags from '../../components/velog/UserTags' ;
13+ import qs from 'qs' ;
14+ import { usePrevious } from 'react-use' ;
1215
1316const UserPageBlock = styled ( VelogResponsive ) `` ;
1417
1518export interface UserPageProps
1619 extends RouteComponentProps < { username : string ; tab ?: 'series' | 'about' } > { }
1720
18- const UserPage : React . FC < UserPageProps > = ( { match } ) => {
21+ const UserPage : React . FC < UserPageProps > = ( { match, location } ) => {
1922 const { username, tab } = match . params ;
23+ const { tag } = qs . parse ( location . search , {
24+ ignoreQueryPrefix : true ,
25+ } ) as { tag : string | undefined } ;
26+
27+ const prevTag = usePrevious ( tag ) ;
28+ useEffect ( ( ) => {
29+ if ( prevTag !== tag ) {
30+ window . scrollTo ( 0 , 0 ) ;
31+ }
32+ } , [ prevTag , tag ] ) ;
2033
2134 return (
2235 < UserPageBlock >
2336 < UserProfileContainer username = { username } />
2437 < MobileSeparator />
2538 < VelogTab username = { username } tab = { tab || 'posts' } />
39+ < UserTags username = { username } tag = { tag || null } />
2640 < Route path = "/@:username" exact component = { UserPostsTab } />
2741 < Route path = "/@:username/series" component = { SeriesTab } />
2842 < Route path = "/@:username/about" component = { AboutTab } />
0 commit comments