From what I understand, your components are set up as follows:
class Parent .... {
....
fetchUser(){
....
}
....
render(){
return (
...
<BaseMap fetchUser={this.fetchUser.bind(this)}/>
...
);
}
}
class BaseMap .... {
....
render(){
let user = this.props.fetchUser();
return (
<div> { ...use user here ... }</div>
);
}
}
Please correct me if I am wrong.
What you are being advised to do is to take the call to fetchUser out of BaseMap components render method and move to its componentDidMount method. Then store the user in the state of the component and use it from there.
class BaseMap .... {
constructor(props){
super(props);
this.state={user:null};
}
componentDidMount(){
let user = this.props.fetchUser();
this.setState({user:user});
}
render(){
return (
<div> {this.state.user?
...use user here ...
: "loading data"
}</div>
);
}
}
fetchUser? Can you post the code for<BaseMap />? Sounds like what they meant is that in<BaseMap />you should be callingthis.props.fetchUserincomponentDidMount?