I'm finding it difficult to create a Browser Route in React. Here is what I want to do:
import React from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import Navbar from './components/navbar/Navbar';
import RecipeList from './containers/recipe-list/RecipeList';
import Recipe from './containers/recipe-details/RecipeDetails';
import Footer from './components/footer/Footer';
import Error from './components/error/Error';
import './App.css';
export default function App() {
return (
<div>
<Navbar />
<BrowserRouter>
<Switch>
<Route exact path="/" component={RecipeList} />
<Route path="./containers/recipe-details/RecipeDetails" component={Recipe} />
<Route component={Error} />
</Switch>
</BrowserRouter>
<Footer />
</div>
);
}
import React from 'react';
import { Link } from 'react-router-dom';
export default function Recipe() {
return (
<div>
<Link to="../../containers/recipe-details/RecipeDetails">Recipe</Link>
</div>
);
}
The problem comes in my Recipe component which I want to create a separate route for.
Thanks in anticipation of your response.