sdh20282 / sdh20282-portfolio

https://sdh20282-portfolio.vercel.app
0 stars 0 forks source link

framer-motion exit animation 관련 #1

Open sdh20282 opened 1 month ago

sdh20282 commented 1 month ago
sdh20282 commented 1 month ago
export function FrozenRouter(props: { children: React.ReactNode }) {
  const context = useContext(LayoutRouterContext ?? {});
  const frozen = useRef(context).current;

  return (
    <LayoutRouterContext.Provider value={frozen}>
      {props.children}
    </LayoutRouterContext.Provider>
  );
}
sdh20282 commented 1 month ago
export function FrozenRouter(props: { children: React.ReactNode }) {
  const context = useContext(LayoutRouterContext);
  const prevContext = usePreviousValue(context) || null;

  const segment = useSelectedLayoutSegment();
  const prevSegment = usePreviousValue(segment);

  const changed = segment !== prevSegment && segment !== undefined && prevSegment !== undefined;

  return (
    <LayoutRouterContext.Provider value={changed ? prevContext : context}>
      {props.children}
    </LayoutRouterContext.Provider>
  );
}
sdh20282 commented 3 weeks ago

현재 page router로 변경 완료, 자잘한 부분 수정 중