【发布时间】:2018-08-03 14:32:31
【问题描述】:
我正在获取ProductList 中的产品列表,其中我需要将选定的产品对象传递给Product。
目前,我正在尝试将 id 作为路由参数传递并再次获取产品对象。但我想将整个产品对象从ProductList 发送到Product。
我的路线是
<Route path={joinPath(["/product", ":id?"])} component={Product} />
ProductList组件链接
<Link to={"/product/" + this.props.product.Id} >{this.props.product.Name} </Link>
如何将产品对象作为道具传递给Product?
下面的在 Typescript 中抛出错误,说 Link Type 上不存在以下属性。
<Link to={"/product/" + this.props.product.Id} params={product}>{Name}</Link>
我尝试了以下问题,但似乎都没有我的问题。
-
Pass props in Link react-router
<--- this is similar to my issue, but answer doesn't work for react-router v4 - react-router - pass props to handler component
- React: passing in properties
【问题讨论】:
标签: javascript reactjs typescript react-router react-router-v4