Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading