๐Ÿ’พ Simple persisted state in react-native

Overview

React Native Use Persisted State

npm version npm download License MIT

Stars Twitter

Preview

Introduce

๐Ÿ’พ Simple persisted state in react-native

๐ŸŒ Globally accessable like redux, recoil...

๐Ÿš€ No loading, Immediate synchronization


Usage

import {View, Text, Button} from 'react-native';
import {usePersistedState} from 'react-native-use-persisted-state';

const Counter = () => {
  const [count, setCount] = usePersistedState('@count', 0);

  return (
    <View>
      <Text>count : {count}</Text>
      <Button onPress={() => setCount(count + 1)} title="increment" />
      <Button onPress={() => setCount(count - 1)} title="decrement" />
    </View>
  );
};

Getting started

First, Install react-native-use-persisted-state & @react-native-async-storage/async-storage

yarn add react-native-use-persisted-state @react-native-async-storage/async-storage

Second, Pod intsall

cd ios && pod install

Third, Add provider

// App.js
...
import {PersistedStateProvider} from 'react-native-use-persisted-state' // here

const App = () => {
  return (
    <PersistedStateProvider> // here
        <.../>
    </PersistedStateProvider> // here
  );
};

API

usePersistedState

Params

usePersistedState<T>(key, initialState);
name type require default description
key string โœ… key used to store storage
initialState T undefined

Returns

const [state, setState, clear] = usePersistedState<T>(...);
name type description
state T same as react state const [state] = useState()
setState (v:T) => void same as react setState const [..., setState] = useState()
clear () => void clear storage and init state to initialState
You might also like...

Admob for React Native with powerful hooks and components

React Native Admob โš ๏ธ Please note, this package is under active development, which means it may be not stable to apply on production. Please use this

Jan 6, 2023

React Native wrapper around Indy SDK Java and Objective-C wrappers.

React Native Indy SDK React Native Indy SDK wrapper. Installation with npm: $ npm install indy-sdk-react-native --save with Yarn: $ yarn add indy-sdk-

Dec 5, 2022

Ship React Native .jsbundles compressed by Brotli algorithm.

Ship compressed JS bundles Warning: not yet available for Android. Sometimes you need a very small .app, for example if you are building an App Clip.

Nov 15, 2022

Prevent Screenshots in your React Native app when needed. ๐Ÿฆ„

React Native Prevent Screenshots Prevent Screenshots in your React Native app when needed. ๐Ÿฆ„ Installation First, you need to install the package usin

Oct 19, 2022

Using turborepo & react-native

Turborepo starter with NPM This is an official starter turborepo. What's inside? This turborepo uses NPM as a package manager. It includes the followi

Feb 16, 2022

This is a Food Delivery Mobile Application. Build Using React Native

This is a Food Delivery Mobile Application. Build Using React Native

Ax Food Delivery Service This is a Food Delivery Mobile Application build using ๐‘๐ž๐š๐œ๐ญ ๐๐š๐ญ๐ข๐ฏ๐ž ๐Ÿ’™ Installation Clone this repository git clon

Jul 14, 2022

Project developed for MB Talk - App Center integration on React Native

App Center Setup Download APK Click here Requirements React Native CLI Yarn Sign Up on App Center and create a new App. How to use this repo Clone thi

Oct 31, 2022

Lottie wrapper for React Native.

Lottie wrapper for React Native.

Lottie for React Native, iOS, and Android Lottie component for React Native (iOS and Android) Lottie is a mobile library for Android and iOS that pars

Jan 7, 2023

Render After Effects animations natively on Android and iOS, Web, and React Native

Render After Effects animations natively on Android and iOS, Web, and React Native

Lottie for Android, iOS, React Native, Web, and Windows Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations expo

Jan 3, 2023
Releases(1.0.2)
  • 1.0.2(Mar 31, 2022)

    What's Changed

    • Remove useCallback by @KoreanThinker in https://github.com/KoreanThinker/react-native-use-persisted-state/pull/3

    New Contributors

    • @KoreanThinker made their first contribution in https://github.com/KoreanThinker/react-native-use-persisted-state/pull/3

    Full Changelog: https://github.com/KoreanThinker/react-native-use-persisted-state/compare/1.0.1...1.0.2

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Mar 29, 2022)

  • 1.0.0(Mar 29, 2022)

Owner
Hyun
They call me Coffee cause I grind so fine. ๐Ÿคฃ
Hyun
With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any other file server

React Native In-App update With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any o

Nepein Andrey 7 Dec 21, 2022
React native wrapper for Jitsi Meet SDK Library that rely on the native view (Activity / ViewController)

react-native-jitsi-meet-sdk React native wrapper for Jitsi Meet SDK Library. This Library implements the Jitsi SDK with a native activity on the Andro

null 7 May 2, 2022
An awesome native wheel picker component for React Native.

โ›๏ธ react-native-picky An awesome native wheel picker component for react-native. Features Supports multiple columns โœ… Supports looping โœ… Native Androi

null 28 Dec 4, 2022
This project is a simple messaging application made using React-Native framework, Gifted-Chat library and Firebase database

This project is a simple messaging application made using React-Native framework, Gifted-Chat library and Firebase database. The example that will be shown here focuses on the ability of two people to message each other in a chat room.

null 3 Jan 30, 2022
The Apache Software Foundation 605 Dec 30, 2022
Representational State Transfer + Structured Query Language(RSQL): Demo application using RSQL parser to filter records based on provided condition(s)

Representational State Transfer + Structured Query Language: RSQL Demo application using RSQL parser to filter records based on provided condition(s)

Hardik Singh Behl 9 Nov 23, 2022
Executable state charts, workflows and more.

Act Getting started If you are using Maven, include the following in your POM: <dependency> <groupId>org.requirementsascode.act</groupId> <a

Bertil Muth 30 Dec 30, 2022
Sync DND state between Android phone and watch

DNDSync This App was developed to enable Do Not Disturb (DND) synchronization between my Pixel phone and the Galaxy Watch 4 since this option was only

rhaeus 56 Dec 19, 2022
A React Native project starter with Typescript, a theme provider with hook to easy styling component, a folder architecture ready and some configs to keep a codebase clean.

React Native Boilerplate Folder structure : src โ”œโ”€โ”€ assets โ”‚ย ย  โ”œโ”€โ”€ audios โ”‚ย ย  โ”œโ”€โ”€ fonts โ”‚ย ย  โ”œโ”€โ”€ icons โ”‚ย ย  โ””โ”€โ”€ images โ”œโ”€โ”€ components โ”‚ย ย  โ”œโ”€โ”€ Layout.tsx

LazyRabbit 23 Sep 1, 2022
Lightweight React Native UI Components inspired on Vant

vant-react-native Install yarn add vant-react-native Or npm install vant-react-native Usage import React, { Component } from 'react'; import { View, T

ๆด›็ซน 51 Sep 29, 2022