If you want to use MMKV with zustand persist-middleware, create the following storage
object:
import { StateStorage } from 'zustand/middleware'
import { MMKV } from 'react-native-mmkv'
const storage = new MMKV()
const zustandStorage: StateStorage = {
setItem: (name, value) => {
return storage.set(name, value)
},
getItem: (name) => {
const value = storage.getString(name)
return value ?? null
},
removeItem: (name) => {
return storage.delete(name)
},
}