2.0.5 • Published 3 years ago

@ugenc/use-storage-hook v2.0.5

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
3 years ago

Simple Hook for React Native AsyncStorage

This package makes the use of Async Storage easier with React Native Project via React Hooks.

It provides you an easier way to update, remove and reach a storage key's value.

Installation

You need to have @react-native-async-storage/async-storage in your React Native project.

For AsyncStorage documentation click here.

Yarn

yarn add @ugenc/use-storage-hook

Npm

npm i @ugenc/use-storage-hook

Usage

First import the hook.

import { useStorage } from '@ugenc/use-storage-hook'

Inside your component call the hook.

import React from 'react'
import { View, Text } from 'react-native'

export default function index() {

  const [storeValue, setStore, removeStore] = useStorage('@key'); // provide a storage key.

    return (
        <View>
            <Text></Text>
        </View>
    )
}
console.log(storeValue) // value of the storage.
setStore(object) // update the storage with the new value.
removeStore() // remove all items in the storage.

Give a star :) on GitHub ugenc

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.3

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago