1- import React , { useEffect , useRef } from "react" ;
1+ import React , { useRef } from "react" ;
22import "./transition.css" ;
33import { TransitionGroup , CSSTransition } from "react-transition-group" ;
44import { useNavigationType } from "react-router-dom" ;
@@ -21,13 +21,14 @@ const PageTransitionWrapper = ({ location, children }: PropsType) => {
2121 const pathname = location . pathname ;
2222 const isBack = location . state ?. isBack as boolean | undefined ;
2323 console . log ( isBack , "이즈백" ) ;
24+
2425 //라우터 이동 방향에 따른 애니메이션 분리
2526 const isNavigatePush = navigateType === "PUSH" && ! isBack ;
26- const isNavigatePop = navigateType === "POP" || isBack ;
27- const isNavigateReplace = navigateType === "REPLACE" ;
27+ const isNavigateReplace = navigateType === "REPLACE" && ! isBack ;
28+
2829 const isAnimation = ( ) => {
2930 if ( isNavigatePush ) return "navigate-push" ;
30- if ( isNavigatePop ) return "navigate-pop" ;
31+ if ( isBack ) return "navigate-pop" ;
3132 if ( isNavigateReplace ) return "" ;
3233 return "" ;
3334 } ;
@@ -41,11 +42,6 @@ const PageTransitionWrapper = ({ location, children }: PropsType) => {
4142
4243 const currentNodeRef = nodeRefs . current [ pathname ] ;
4344
44- useEffect ( ( ) => {
45- if ( isNavigatePush || isNavigatePop ) {
46- window . scrollTo ( 0 , 0 ) ;
47- }
48- } , [ pathname , isNavigatePush , isNavigatePop ] ) ;
4945 return (
5046 < TransitionGroup
5147 className = { "transition-wrapper" }
0 commit comments