Web Local && Session Storage
INSTALL
npm install local-session-storage
EXAMPLES
let Storage = ; or ;
On React js set your storage after setState()
{ let name = eventtargetname let value = eventtargetvalue; this /***LOCAL**/ StorageLocal /***OR SESSION**/ StorageSession }
On React js get your storage on refresh page ore on change component and return to it
{ /*****WE USE THE LIVE FUNC****** * On react if you use a normat localStorage.getItem you dont have the last value but one older value. * On package local-session-storage is used the Promise resolve * And for this example you can use: ***************************/ /******LOCAL*********/ let that_ = this StorageLocal /***SESSION*****/ StorageSession /**Normaly you can use**/ let storage = StorageLocal; let session = StorageSession; }
Clear && Remove
StorageLocalclear; // clear all obj on local storage for you domain StorageSessionclear; // clear all obj on local storage for you domain StorageLocal // remove the objname name with values on local storage StorageSession // remove the objname name with values on session storage
Length && LengthAll of a key stored to session or local storage
let lengthObjLocal = StorageLocallength'objname';let lengthObjSession = StorageSessionlength'objname'; let LengthAllLocal = StorageLocal;let LengthAllSession = StorageSession;
Note: This examples are used for react js but you can use this library on all js framework
Thank You