使用withRouter()时,如何获得路由上下文,位置,参数等?
import { withRouter } from 'react-router';
const SomeComponent = ({location, route, params}) => (
<h1>The current location is {location.pathname}</h1>
);
const ComposedWithRouter = withRouter(SomeComponent);
Run Code Online (Sandbox Code Playgroud)
您可以使用withRouter获取该信息,还是必须在组件树中明确传递这些内容?