I have a list of item that's rendered using map, then using socket.io a new item is added to the list, I have a click listener on every item.
But have an issue where my this.props.history.push
is not working during the first click. The page is just not changing, it changed when I trigger it for the second time.
console.log(id) //yes it's always present
this.props.history.push(`/job/${id}`)
What's the problem?
如果您使用的是反应路由器和路由没有被渲染与<Route />
你需要用你的组件withRouter()
为了能够访问this.props.history.push
阅读更多这里基本上withRouter()
将创造历史和匹配和位置, 不是被渲染的反应路由器组件可用于我们!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.