reactjs - How to persist certain redux store properties to disk? -


in redux app have settings should persisted disk when change (as json file) , loaded app (to fill initial state of store).

i guess app settings state, belong in store. have actions modify settings, either settings/change payload {name:'settingname', value: 'settingvalue'} or fine grained settings/units payload 'metric' or 'imperial'.

now need intercepts state changes/action submissions , persist them disk serialized json. settings reducer should or better kind of middleware can perform async in background?

how in code?

you may use localstorage api krs said. care because allows string values, may need stringify objects before storing them:

var config = {     foo: 'foo',     bar: 'bar' }  // store: localstorage.setitem('config', json.stringify(config));  // json.parse(localstorage.getitem('config')); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

python - cx_oracle unable to find Oracle Client -