rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.97k stars 867 forks source link

Persist Gate loading time #1174

Open Florent75 opened 4 years ago

Florent75 commented 4 years ago

Hi,

Here is my context :

My app is taking 5 s on cold start, Just to go from App.js to the "initialRouteName" configured in navigation.js.

If I remove :

Is it some kind of a regular behaviour ? How can I decrease this startup time ?

holmberd commented 4 years ago

Sounds like you are hitting the default timeout (which is 5s), see https://github.com/rt2zz/redux-persist/blob/master/src/persistReducer.js#L24

Florent75 commented 4 years ago

Hi Holmberd,

Thanks a lot for this link, you are perfectly right. If I set the timeout to 1000, it does startup in 1000ms.

I am still wondering what timeout I shoud put, and moreover, is my redux well persisted if I set a timeout of 1ms (which seem "quite" fast) ?

Thanks

hirbod commented 4 years ago

I would also like to know how we can optimize this

voxspox commented 4 years ago

Do you still have the problem? @Florent75 @Hirbod

I read the code here: https://github.com/rt2zz/redux-persist/blob/master/src/persistReducer.js#L89 that if the timeout is reached the previous state could not be restored and is empty. This read error silently fails...

ArisPapaiakovou commented 2 years ago

Hey Guys I have the 5s issue as well, unfortunately both links #L27 and #L89 are 404ing :(

Update: Found it: const persistConfig = { timeout: 1000, key: "root", storage: AsyncStorage, // stateReconciler: autoMergeLevel2, };

HAZberi commented 2 years ago

Hey Guys I have the 5s issue as well, unfortunately both links #L27 and #L89 are 404ing :(

Update: Found it: const persistConfig = { timeout: 1000, key: "root", storage: AsyncStorage, // stateReconciler: autoMergeLevel2, };

Thanks a lot @ArisPapaiakovou! I was having the same 5s issue. It took me a long time just to understand that the issue is coming from a default timeout setting on Persist Gate loading. This "config" workaround should be included in the docs for sure.