Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.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 正在传递路由,但未渲染组件_Reactjs_React Router - Fatal编程技术网

Reactjs 正在传递路由,但未渲染组件

Reactjs 正在传递路由,但未渲染组件,reactjs,react-router,Reactjs,React Router,我的问题是关于这条线的第一条路线: <Route path="/products/:id" Component={ProductDetails} /> 您正在通过组件道具将组件传递到路由,但它应该是组件 <Route path="/products/:id" component={ProductDetails} /> oh lol谢谢,是的component@UnskilledCoder哈哈,这是常有的事。不客气。 impor

我的问题是关于这条线的第一条路线:

<Route path="/products/:id" Component={ProductDetails} />

您正在通过
组件
道具将组件传递到
路由
,但它应该是
组件

<Route path="/products/:id" component={ProductDetails} />


oh lol谢谢,是的component@UnskilledCoder哈哈,这是常有的事。不客气。
import React, { Component } from "react";

class ProductDetails extends Component {
  handleSave = () => {
    // Navigate to /products
  };

  render() {
    return (
      <div>
        <h1>Product Details - </h1>
        <button onClick={this.handleSave}>Save</button>
      </div>
    );
  }
}

export default ProductDetails;
<Route path="/products/:id" component={ProductDetails} />