I'm trying to display a UI Overlay during the save process. I'm dispatch the ui change using a thunk, but the problem is it waits for the Promise to resolve before re-render occurs. There is a longPromise() in my code (can take around 10 seconds to action) so it's currently waiting 10 seconds before the indicator appears.
Any advice/pattern would be appreciated. Thanks in advance!
save(values, validate, props){
const {
dispatch,
setOverlay
} = props;
return dispatch( setOverlay(true, 'Saving User...') )
.then(() => {
return longPromise();
});
}
render(){
const { handleSubmit } = this.props;
return (
<form onSubmit={ handleSubmit(this.save) }>
<span>Form fields here</span>
</form>
)
}