In the reducer, I need to read data from localStorage to decide the count of record, so that the defaultly selected item's name can be decided. Is it possible to use localStorage in redux reducer?
code,
const ugData = JSON.parse(localStorage.getItem("ugData"));
const defaultState = {
...
// if in the localstorage,
// use allgroups length to decide
// the selected item's name
selectedGroupName: ugData.allGroups.length > 0 ? ugData.allGroups[0].name:"" ,
}
currently, I get errors like this,
ReferenceError: localStorage is not defined
ideas are welcome.