Skip to content

DmitriyNikolenko/reactn-persist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contents

About

Add persist functionality to reactn global storage.

Installation

yarn add reactn-persist

or

npm install reactn-persist

Usage

Use pertsist.

import initReactnPersist from './reactn-persist';

initReactnPersist({
	// REQUIRED.
	storage: AsyncStorage, // localStorage, sessionStorage or any instance with Storage API interface support.
	// Optional.
	whitelist: [], // List of top-level keys in global, like ['users', 'token']. Default [].
	debug: false, // Enable console.log mode. Default false.
	key: '@reactn', // Key in storage. Default '@reactn'.
	debounceDelay: 1000, // Persist debounce delay. Default 1000ms.
	initialValue: {}, // Object that will be merged with rehydrated global. Default {}.
	provider: ReactNProvider, // ReactN Provider instance (if you want to use Provider).
});

Use pertsisted status value.

import { useGlobal } from 'reactn';
import { REHIDRATED_KEY } from './reactn-persist';
const [rehidrated] = useGlobal(REHIDRATED_KEY);

TODO

  • Blacklist

Changelog

  • 1.3.2 - fix a undefined import instead of setGlobal and getGlobal when you are using ReactN without Provider (thanks @DomThePorcupine, @Vladislava9009).
  • 1.3.1 - filter persisted data keys which are absent in whitelist (if it exist) during rehydration (thanks @truongngodang).
  • 1.3.0 - add support for ReactN Providers (thanks @vjsingh), update Typescript declarations.
  • 1.2.2 - fix Typescript declaration file.
  • 1.2.0 - added Typescript declaration file.
  • 1.1.0 - added rehydrated status and export rehydrated key name (REHIDRATED_KEY).
  • 1.0.0 - release.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published