Closed feat7 closed 6 years ago
mobx-persist doesn't support sessionStorage. So I went for localForage
.
Problem was, localForage too doesn't support sessionStorage
.
So I forked localForage and added support for sessionStorage. Since I needed the patch as soon as possible, I went on to create a new module instead of pull request to localForage.
Here is the client-persist package for sessionStorage support.
yarn add client-persist
or
npm install client-pesist
import { create } from 'mobx-persist';
import clientPersist from 'client-persist';
// to use sessionStorage
clientPersist.setDriver(clientPersist.SESSIONSTORAGE)
hydrate = create({ storage: clientPersist }).then(() => /*do something*/ );
mobx-persist right now supports only localStorage, localForage and AsyncStorage. It would be better if it can support sessionStorage.
hydrate = create({ storage: sessionStorage }).then(() => /*do something*/ );
This will not work as create returns null.