从reactJS中的react路由器链接传递道具

从reactJS中的react路由器链接传递道具,reactjs,Reactjs,如何使用React路由器链接将道具传递给另一个组件 我试着这样做。然而,它不起作用。 我的意思是道具没有通过。 我想将货币信息传递给另一个组件,然后使用它。 有什么建议吗 return <Div> <div className="header"> <Heading>Welcome To CoinValue </Heading> </div> &l

如何使用React路由器链接将道具传递给另一个组件

我试着这样做。然而,它不起作用。 我的意思是道具没有通过。 我想将货币信息传递给另一个组件,然后使用它。 有什么建议吗

return <Div>
        <div className="header">
            <Heading>Welcome To CoinValue </Heading>
        </div>
        <Ul>
            {currentItems.map(currencies => {
                return <Link
                    key={uuidv4()}
                    to={`/cryptoValute/${currencies.id}`
                    props={currencies}}><Li>{currencies.name}</Li></Link>
            })}
            <div>
                {this.renderPagination()}
            </div>
        </Ul>
    </Div>
返回
欢迎来到CoinValue
    {currentItems.map(货币=>{ 返回
  • {currences.name}
  • })} {this.renderPagination()}

再见,请尝试如下修改您的代码:

return <Div>
    <div className="header">
        <Heading>Welcome To CoinValue </Heading>
    </div>
    <Ul>
        {currentItems.map(currencies => {
            return <Link
                key={uuidv4()}
                to={{pathname: `/cryptoValute/${currencies.id}`, query: {currencies}}}><Li>{currencies.name}</Li></Link>
                
        })}
        <div>
            {this.renderPagination()}
        </div>
    </Ul>
</Div>
返回
欢迎来到CoinValue
    {currentItems.map(货币=>{ 返回
  • {currences.name}
  • })} {this.renderPagination()}

然后在您的组件中,要检索
货币
值,您可以执行
this.props.location.query.currences

您能否更好地描述一下您希望通过此代码实现的功能?您只需将道具传递给另一个组件,而无需使用。这是否回答了您的问题@阿尔伯特·奥佩雷斯我特别需要通过link@k-wasilewski我正在尝试这种方法,但仍然无法使它成为这一行的synax错误
to={{{pathname:
/cryptoValute/${currencies.id}
,query:{currencies}}
`哦,对不起,我在查询之后错误地放了一个。我更新了我的答案。现在检查一下。