An example of using Ionic Storage with React
new Storage()with config using Driverscreate()set()get()remove()clear()- Some custom functions for accessing arrays of objects
Based on the "list" Ionic React starter template
-
All
@ionic/storagefunctionality is inIonicStorage.jswithin the data folder -
Pass any name to the
createStorefunction to name your DB -
Mimic of data fetching from
messages.jsjust like in the list starter template -
Fetched data is placed into Ionic Storage then manipulated throughout
-
Upon "refresh", if the
msgskey exists in Ionic Storage, this will be used instead of fetching
To reset: within DevTools > Application, delete the IndexedDB created. It will then be re-created and populated with fetched data.
Are you on Twitter? Lets connect @93alan If you'd like to support, you can buy me a coffee ☕️