Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 600 Bytes

WRAPPER_REDUX.md

File metadata and controls

25 lines (21 loc) · 600 Bytes

redux-persist storage wrapper

If you want to use MMKV with redux-persist, create the following storage object:

import { Storage } from 'redux-persist'
import { MMKV } from "react-native-mmkv"

const storage = new MMKV()

export const reduxStorage: Storage = {
  setItem: (key, value) => {
    storage.set(key, value)
    return Promise.resolve(true)
  },
  getItem: (key) => {
    const value = storage.getString(key)
    return Promise.resolve(value)
  },
  removeItem: (key) => {
    storage.delete(key)
    return Promise.resolve()
  },
}