Invariant failed: You should not use outside a

后端 未结 20 1261
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 20:55

I use react-router-dom for routing in my React application. Part of my app extracted in another package. List of dependencies looks like this:

相关标签:
20条回答
  • 2020-12-03 21:24

    Use Router outside of your components. Wrap all components inside the Router then will able to use Link in your components.

    import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

    <Router>
            <Appbar />
            <Switch>
              <Route exact path="/" component={Home} />
              <Route path="/mac" exact component={Mac} />
            </Switch>
           <Footer />
          </Router>
    
    0 讨论(0)
  • 2020-12-03 21:25

    Trouble with 2 instance of React

    0 讨论(0)
提交回复
热议问题