react props 打印为空
不知道 这里props为啥打印为空,初学react不知道该如何解决。
你 constructor 传入的 prop少写了 一个s
constructor(props){
super(props)
}
react-router v6 解决props为空
import { useLocation, useNavigate, useParams } from "react-router";
export function withRouter(Child) {
return (props) => {
const location = useLocation();
const navigate = useNavigate();
const params = useParams();
return (
<Child
{...props}
navigate={navigate}
location={location}
params={params}
/>
);
};
}