Closed mzafer closed 5 years ago
Can you provide a test repo that demonstrates the issue and I'll help look into it?
I think it might be because your OnBeforeLift argument is a function that is simply firing, then PersistGate moves on, without waiting for the Promise to resolve. Can you try...
return (
<PersistGate
onBeforeLift={ async () => { await this.loadSettings() } }
persistor={persistor}
/>
);
or maybe just
return (
<PersistGate
onBeforeLift={this.loadSettings()}
persistor={persistor}
/>
);
I believe onBeforeLift can take a function or a Promise to resolve.
@mzafer Let me know if you still are having a hard time with this and I'll re-open.
I have the below code in my component and I want to prevent App from being mounted and rendered before the settings are loaded. My understanding is the onBeforeLift will gate the App from being loaded till the loadSettings method is completed but the App is rendered before that.
return (
Below is my loadSettings function, The SettingsRepo.getSettings() returns a promise.
async function loadSettings() { await SettingsRepo.getSettings(); return; }
Am I doing anything wrong ? How do I prevent App from being mounted till the Settings are loaded ?