xxxxxxxxxx
const [searchParams, setSearchParams] = useSearchParams();
searchParams.get("__firebase_request_key")
xxxxxxxxxx
import React from "react";
import { useLocation } from "react-router-dom";
const MyComponent = () => {
const search = useLocation().search;
const id=new URLSearchParams(search).get("id");
console.log(id);//12345
}
xxxxxxxxxx
//in route
<Route path="child/:id" children={<Child />} />
// in component
import { useParams } from "react-router-dom";
let { id } = useParams();
import { useLocation } from 'react-router-dom';
//url = http://localhost:3000/main/ride?params=1
const location = useLocation();
const [value, setValue] = useState( new URLSearchParams(location.search).get('params'));
console.log(value) // 1
xxxxxxxxxx
<Route path="/users/:id" render={(props) => <UserPage {props} />}/>
this.props.match.params.id