Если вы хотите использовать response-router-dom, вы должны использовать Router, Switch, Route, Link , например, из "response-router-dom"
, рассмотрите эти файлы:
в index.js
import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter} from 'react-router-dom';
import App from './app/App';
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>, document.getElementById('root'));
в App.js
import React from "react"
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom"
import categoryIndex from "../components/category/index"
import productIndex from "../components/product/index"
clas App extends Component {
render(){
return (
<Router>
<div className="container"
<Link to={"/category/index"} className="nav-link">
Categories
</Link>
<Link to={"/products/index"} className="nav-link">
Products
</Link>
<Switch>
<Route path="/category/index" component={categoryIndex} />
<Route path="/product/index" component={productIndex} />
</Switch>
</div>
</Router>
);
}
}
export default App;
и затем в вашей целифайл:
<div id='createNewProduct'>
<Link to={"/product/create"}>
+ Create New Product
</Link>
</div>