Skip to content
Kevin edited this page Jan 24, 2024 · 2 revisions

React Native Data Store Module Documentation

Introduction

The react-native-data-store module provides a convenient way to manage a data store in your React Native applications. It allows you to read, write, clear values, and even clear the entire data store.

Installation

Make sure to install the react-native-data-store package in your React Native project.

If not installed, install the package

yarn add react-native-data-store
npm install react-native-data-store

Methods

Method Description Parameters Returns
readDataStoreValue Reads a value from the data store for a given key. key: string Promise
writeDataStoreValue Writes a value to the data store for a given key. key: string, value: string Promise
clearDataStoreValue Clears a specific value from the data store for a key. key: string Promise
clearDataStore Clears the entire data store, removing all values. Promise

Usage

Reading Data from the Data Store

const myValue = await readDataStoreValue('myKey');
console.log('Value from the data store:', myValue);

Writing Data to the Data Store

await writeDataStoreValue('myKey', 'Hello, Data Store!');
console.log('Value written to the data store successfully.');

Clearing a Specific Value from the Data Store

await clearDataStoreValue('myKey');
console.log('Value for "myKey" cleared from the data store.');

Clearing the Entire Data Store

await clearDataStore();
console.log('Data store cleared. All values removed.');
`