누구냐 const router = useRouter()

BellBoy·2023년 5월 28일
0
post-custom-banner

https://nextjs.org/docs/app/api-reference/functions/use-router

import { useRouter } from "next/navigation";

라우터를 참 쉽게 만들어주는 녀석!

}, [pathname, searchParams]);

return null;

'use client';
 
import { useEffect } from 'react';
import { usePathname, useSearchParams } from 'next/navigation';
 
export function NavigationEvents() {
  const pathname = usePathname();
  const searchParams = useSearchParams();
 
  useEffect(() => {
    const url = pathname + searchParams.toString();
    console.log(url);
  }
    // You can now use the current URL
    // ...
profile
리액트러버
post-custom-banner

0개의 댓글