相关疑难解决方法(0)

使用带路由器的React路由器

使用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获取该信息,还是必须在组件树中明确传递这些内容?

reactjs react-router

10
推荐指数
1
解决办法
3万
查看次数

标签 统计

react-router ×1

reactjs ×1