Answer the question
In order to leave comments, you need to log in
How to create an intermediary for loading a react component?
there is a code:
import React, {Component} from 'react';
import {Route, Switch} from 'react-router-dom';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import ContentIndex from '../pages/ContentIndex';
import Catalog from '../pages/Catalog';
class Root extends Component {
render(){
return(
<div className="all-data">
<Switch>
<Route
exact
path={"/"}
component={ContentIndex}
/>
<Route
path={'/catalog'
component={Catalog}
/>
</Switch>
</div>
)
}
}
<Route
exact
path={"/"}
component={loadableComponent( ContentIndex )}
/>
import React from "react";
import Page from './Page';
const loadableComponent = (Component) => (
<Page main={'Component'} />
)
export default loadableComponent;
import React, {Component} from 'react';
export default class Page extends Component {
constructor(props) {
super(props);
console.log('test calculate')
}
render() {
return (<div>{this.props.main}</div>);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question