Skip to content
Advertisement

React Routing doesnt render

I have tried to learn React and now wanted make a Route but it seems like it doesnt render Overview. Iam thankful for any help.

import Sidebar from "./components/Sidebar";
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom';
import Overview from "./pages/Overview";

function App() {
  return (
    <Router>
      <Sidebar />
      <Switch>
        <Route path="/overview" components={Overview} />
      </Switch>
    </Router>
  );
}

export default App;
import React from 'react';

const Overview = () => {
  return (
    <>
      <div>Please Render!!</div>
    </>
  )
};

export default Overview;

Advertisement

Answer

You have type error, you write components instead of component. Change this

<Route path="/overview" components={Overview} />

to this

<Route path="/overview" component={Overview} />
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement