history.push() state 값 넘기기

BackEnd_Ash.log·2021년 6월 2일
0

react

목록 보기
38/41

📌 history.push()

보내는쪽 component

import {useHistory} from "react-router-dom"

        history.push({
            pathname: "/detailboard",
            state:id
        });

받는쪽 component

import {useHistory,useLocation} from 'react-router-dom'

const location = useLocation();

console.log(location.state); // 2
profile
꾸준함이란 ... ?

0개의 댓글