componentDidMount is no longer called when react-router is deployed

Asked 2 years ago, Updated 2 years ago, 75 views

Sample Redux code.React-router was introduced in async.However, when I created index.js and routes.js as follows, the componentDidMount of containers/App.js was not called and the View disappeared.Do you know what's wrong?

index.js

import 'babel-polyfill';
import React from 'react';
import {render} from 'react-dom';
import {Provider} from 'react-redux';
import {Router, useRouterHistory} from 'react-router';
import {createHashHistory} from 'history';
import configureStore from'./store/configureStore';
import routes from './routes';

history=useRouterHistory(createHashHistory)({queryKey:false});
conststore=configureStore();

render(
  <Provider store={store}>
    <Router history={history} routes={routes}/>
  </Provider>,
  document.getElementById('root')
)

routes.js

import React from 'react';
import {Route, IndexRoute} from 'react-router';

import {App} from './containers/App';


export default(
    <Route path='/'>
      <IndexRoute component={App}/>
    </Route>
);

There are no specific errors.

javascript reactjs redux

2022-09-30 21:13

1 Answers

import {App} from './containers/App';

not

import App from'./containers/App';

I think it is the case.I think there is an error in the browser console.


2022-09-30 21:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.