What's this error in my react project on my codesandbox?

I get this error in my project on Codesandbox. While it doesn’t get an error on Webstorm:

Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: undefined. You
likely forgot to export your component from the file it’s defined in,
or you might have mixed up default and named imports.

See my project: https://codesandbox.io/s/practical-pateu-hptsrx

But I exported all my components. Any idea?

>Solution :

Switch is no longer supported in router v6, you can use Routes instead and use Element as attribute instead of component.

import { BrowserRouter as Router, Route, Routes } from "react-router-dom";

<Routes>
    <Route path="/" element={<Home/>} />
    <Route path="/create" element={<Create />} />
</Routes>

Leave a Reply