0

在我完全发疯之前请帮助我。已经调试了 3 天没有运气:( 我有这个组件在反应

 import Routes from './routes'
 import { I18nextProvider } from 'react-i18next'
 import React, { Component , Suspense } from 'react';
 import { Provider } from 'react-redux'
 import { ConnectedRouter } from 'connected-react-router'
 import APPWrapper from 'APPWrapper'
 import { ToastContainer } from 'react-toastify';
    
 class App extends Component {
    render() {
        return (
         <Suspense fallback={"Loading"}>
               <I18nextProvider i18n={ i18n }>
                    <Provider store={store}>    
                        <ConnectedRouter history={history}>
                            <ToastContainer/>
                            <APPWrapper>
                                 <DisconnectedWarning />
                                 <Routes />
                            </APPWrapper>
                        </ConnectedRouter>
                    </Provider>
                </I18nextProvider>
           </Suspense>
     );
  }
}

App.contextTypes = { store: PropTypes.object };

export default App;

然后路线看起来像这样

import {
    Route, Switch
} from 'react-router-dom';
export default ()=> {
    return (
        <Switch>
            <Route exact path="/" key="redirectHome"  component={(props) => <RedirectHome {...props} />} />
            <Route exact path="/login" key="UserLogin"  component={(props) => <UserLogin {...props} />} />
            ....
        </Switch>
)}

好吧,还有其他组件也可以渲染开关,但我认为这并不重要,因为它们都是 APPWrapper 的子组件。

当我渲染这个时,我得到一个You should not use <Route> or withRouter() outside a <Router>

"redux": "^4.0.5", "react-redux": "^7.2.4", "react-router-dom": "^4.3.1", "connected-react-router": "^6.9.1",

4

0 回答 0