Is it possible to record component Route in the active state?

Is it possible to record component Route in the active state?

Ie I need ContentIndex record in the state when it is active

import React {Component,Suspense,lazy} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {ConnectedRouter} from 'connected-react-router';
import ScrollToTop from 'react-router-scroll-top';
import {Route, Switch} from 'react-router-dom';
import Head from '../common/Head';
import Header from '../common/Header';
import the Footer from '../common/Footer';

const ContentIndex = lazy(() => import('../pages/ContentIndex'));

class Root extends Component {

 constructor(props) {
super(props);
 this.state = { Component : null }
}

 render() {
 return (
 <ConnectedRouter history={this.props.history}>
<ScrollToTop>
<Head/>
<Header/>
 <div className="all-data">
 <Suspense fallback={<h2>Product list is loading...</h2>}>
<Switch>
<Route
exact
path={"/"}
render={ContentIndex}
/>
</Switch>
</Suspense>
</div>
<Footer/>
</ScrollToTop>
</ConnectedRouter>
)
}

}
matchDispatchToProps function(dispatch) {
 return bindActionCreators({ }, dispatch)
}
export default connect(state => ({router: state.router}), matchDispatchToProps)(Root);
March 23rd 20 at 18:47
0 answer

Find more questions by tags React