import { Route, Switch, BrowserRouter } from 'react-router-dom'
const routing = () => {
console.log(BrowserRouter)
return(
<BrowserRouter>
<Switch>
<Route exact path="/" component={Home} />
</Switch>
</BrowserRouter>
)
}
When I try to use BrowserRouter, it throws ReferenceError: BrowserRouter is not defined
but when I console log it. It seems to be there.
I'm using version 4.2.2 of react-router-dom
.
My mind run out of ideas of what could be the reason and I couldnt find anything in google either ;s
首先,您需要导入React,然后可以将console.log(BrowserRouter)
放入componentWillMount
;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.