How to pass params into link using React router v6?

Using react-router-dom v6

Parent component (App)

<Route path="/something/:id" element={<Something />} />

Child component (Something)

import { useParams } from "react-router-dom";

const Something = (props) => {

    let { id } = useParams(); 

    useEffect(() => {
        console.log(`/something/${id}`);
    },[]);

    // .....

}

Leave a Comment