Hey.
I am trying to do my first react app and everything is working fine, until I tried to use react-router-dom.
I've just imported:
import BrowserRouter from 'react-router-dom';
and wrapped my existing functioning app with
./src/App.js
Attempted import error: 'react-router-dom' does not contain a default export (imported as 'BrowserRouter').
I saw a lot of similar bugs, but most of them have problems when importing from react-router instead of react-router-dom, and other problems were solved after deleting node_modules and restarting the server, but this didn't work for me.
I've tried other react-router-dom versions, but I had the same problem. Here are the versions I tried: 5.2.0, 5.1.0, 5.0.0.
If I open BrowserRouter.js, it has "export default BrowserRouter;", so I don't know what is happening.
Am I missing something os this is really a bug?
It doesn't have a default export: https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/modules/index.js
You need to use a named import: import { BrowserRouter } from 'react-router-dom'
Thank you, I can't believe it was so simple. Sorry for the inconvenience.
Most helpful comment
It doesn't have a default export: https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/modules/index.js
You need to use a named import:
import { BrowserRouter } from 'react-router-dom'