我在BrowserRouter
内部使用Route,但是仍然出现错误,我不确定自己做错了什么
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from 'redux';
import {Provider} from 'react-redux';
import {BrowserRouter} from 'react-router-dom';
import App from './App/index';
import * as serviceWorker from './serviceWorker';
import reducer from './store/reducer';
import config from './config';
const store = createStore(reducer);
const app = (
<Provider store={store}>
<BrowserRouter basename={config.basename}>
<App />
</BrowserRouter>
</Provider>
);
ReactDOM.render(app, document.getElementById('root'));
答案 0 :(得分:0)
我认为您应该像这样使用withRouter()
。
export default withRouter(connect(mapStateToProps)(Something));
此document可能对您有帮助