I have a React component where i want to await the response of a callback function, to set a state, that is controlling rather the component isLoading or not
write now i have a functions like this:
makeRequestHandler = () =>{
this.setState({isLoading: true})
this.props.callbackfn()
this.setState({isLoading: false})
}
the problem here is obviously, that the state is not waiting for the callback function to finish..
The reason i did this pattern is to have a bigger component to hold all the callback functions and render them to each specefic component..
So instead of calling the function directly, i wrap it inside a handler when i press the button:
<Button variant="contained" color="primary" className={"button"} onClick={this.makeRequestHandler}>
later on i would like to each more functionality to each component, but It's all based on awaiting the callbackfunction to finish.
Loading
:{response}