Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Url更改时路由不呈现组件_Reactjs_Redux_React Router - Fatal编程技术网

Reactjs Url更改时路由不呈现组件

Reactjs 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}`}>

我有下面的ProductThumbnail组件,当我点击链接时,它会更新URL并更改重定向到ProductDesc组件的路径。它正确地生成URL/productDescRedux/itemId

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中提供您的代码。它将帮助其他人更好地理解您的问题