当它在react开发工具中显示时,从this.props.match.params获取空值

问题描述 投票:2回答:1

嗨,我试图从我的反应路由器访问我的参数但它总是显示我一个空对象。

这是我的代码:

    <Switch>
    <Route exact path='/' render={(props) => (<PhotoWall {...this.props}/>)}/>
    <Route path='/single/:id' render={(props) => (<Single {...this.props}/>)}/>
    </Switch>

我可以在react开发工具中看到我的params的价值。但我无法访问this.props.match.params .. enter image description here

reactjs react-router react-redux react-router-redux
1个回答
1
投票

看起来你正在调试Component的状态而不是你正在处理的组件道具(屏幕截图上方有一个State标签)?

© www.soinside.com 2019 - 2024. All rights reserved.