我想从链接显示状态,如下所示:
<Link to={{ pathname: '/courses/product/productlist', state: { fromDashboard: true }}}> Food & Treats </Link>
如何在组件中显示状态?
州将在location
道具内部组件中提供。
访问这样的状态:
render(){
console.log('state', this.props.location.state.fromDashboard);
return (....)
}
查看Doc了解更多详情。