Reactjs Url更改时路由不呈现组件
我有下面的ProductThumbnail组件,当我点击链接时,它会更新URL并更改重定向到ProductDesc组件的路径。它正确地生成URL/productDescRedux/itemIdReactjs Url更改时路由不呈现组件,reactjs,redux,react-router,Reactjs,Redux,React Router,我有下面的ProductThumbnail组件,当我点击链接时,它会更新URL并更改重定向到ProductDesc组件的路径。它正确地生成URL/productDescRedux/itemId const ProductThumbnail = (props) => { const itemId = props.product return( <div> <Link to={`/productDescRedux/${itemId.id}`}>
const ProductThumbnail = (props) => {
const itemId = props.product
return(
<div>
<Link to={`/productDescRedux/${itemId.id}`}>
<div>
<h1>{props.product.headline}</h1>
<img src={props.product.images[0].imagesUrls.entry[1].url} alt="Thumbnail small pic"/>
<p></p>
</div>
</Link>
</div>
)
}
ProductThumbnail.propTypes = {
product: React.PropTypes.object
};
export default ProductThumbnail;
//在另一个文件中
const Main = (props) => ({
render(){
return (
<div>
{React.cloneElement(props.children, this.props)}
</div>
)
}
})
export default Main;
const Main=(道具)=>({
render(){
返回(
{React.cloneElement(props.children,this.props)}
)
}
})
导出默认主;
所以我不明白为什么在更改URL时,路由没有调用组件ProductDesc。有什么见解吗 主组件上的语法问题,它是所有组件的父组件。我需要
{React.cloneElement(this.props.children, this.props)}
而不是
{React.cloneElement(props.children, this.props)}
主要组件的语法问题,它是所有组件的父组件。我需要
{React.cloneElement(this.props.children, this.props)}
而不是
{React.cloneElement(props.children, this.props)}
路线层次结构中声明的
ProductThumbnail
在哪里?它是ProductsGrid
的孩子吗?是的,我在ProductsGrid中以孩子的身份调用它。你能把你的App
组件代码也包括进来吗?或者在gist或jsbin中提供您的代码。这将有助于其他人更好地理解您的问题路由层次结构中声明了product缩略图
?它是ProductsGrid
的孩子吗?是的,我在ProductsGrid中以孩子的身份调用它。你能把你的App
组件代码也包括进来吗?或者在gist或jsbin中提供您的代码。它将帮助其他人更好地理解您的问题