npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-redux-persist2

v0.0.3

Published

This is a library that helps you to persist your redux store and rehydrate it when the app is reloaded in your mobile app using react-native or expo with redux.

Downloads

35

Readme

React Native Redux Persist

JS README

Description

This is a library that helps you to persist your redux store and rehydrate it when the app is reloaded. It uses the mobile storage to save the data. You can use it with react-native and expo using the same code. Project is written in TypeScript. However, you can use it in JavaScript projects as well.

Storages supported

  • AsyncStorage (React Native and Expo)
    • type: "AsyncStorage"
  • Expo Secure Store (Expo)
    • type: "expo-secure-store"
    • options: ExpoSecureStoreOptions
      • authenticationPrompt: string
      • keychainAccessible: KeychainAccessibilityConstant
      • keychainService: string
      • requireAuthentication: boolean
  • Generic Storage (React Native and Expo)
    • type: "GenericStorage"
    • driver: GenericStorageType

Expo Secure Store Options

interface ExpoSecureStoreOptions {
	authenticationPrompt?: string;
	keychainAccessible?: KeychainAccessibilityConstant;
	keychainService?: string;
	requireAuthentication?: boolean;
}

Installation

NPM

npm install react-native-redux-persist2

Yarn

yarn add react-native-redux-persist2

Usage

@Reduxjs/toolkit

import { configureStore, createSlice } from "@reduxjs/toolkit";

import {
	persistReducer,
	initStore,
	PersistConfig,
} from "react-native-redux-persist2";

// Example of a reducer
const exampleSlice = createSlice({
	name: "example",
	initialState: {
		value: 0,
	},
	reducers: {
		increment: (state) => {
			state.value += 1;
		},
	},
});

// Here you will pass all your reducers
const reducers = {
	example: exampleSlice.reducer,
};

const rootReducer = persistReducer(reducers);

const store = configureStore({
	reducer: rootReducer,
});

const configs: PersistConfig = {
	key: "root", // Key to store the data
	storage: {
		type: "AsyncStorage", // The storage that you want to use
	},
};

// This will initialize the store and rehydrate it
initStore(store, configs);

export default store;

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

or you can use

How to integrate with React Native or Expo

In your root component, you will wrap your components with the Provider from react-redux.

import React from "react";

import { Provider } from "react-redux";
import store from "./redux/store"; // Is the persistor that you created and exported in the previous step

function App() {
	return <Provider store={store}>{/* Your components */}</Provider>;
}

License

MIT

Author

Gabriel Logan