In my application,the home page fetches the Json response from my rest API.Then I add the products into the cart array.Initially,my store values are..
const DEFAULT_STATE_TRENDING = {
data:{},
specialoffdata:[],
banner:[],
offerstitle:[],
cart:[],
cartcount:0,
isFetching:false,
dataFetched:false,
error:false,
}
After i added the products the cart array and cart count becomes..
cart:[{...},{...}],
cartcount:cart.length
Now, i close my app.After reloading the app,the cart array becomes empty.How to persist the store values here?
The best way to persist the store values is by using this awesome library. Redux Persist
It contains various methods
and levels
of persistance
, with the ease of use.
Installation
and basic usage
is well documented on their github docs.