Skip to content

Releases: ammarahm-ed/react-native-mmkv-storage

v0.6.4

22 Sep 18:53

Choose a tag to compare

  • Add support for monorepo projects
  • Fix falsy value not being set in hook #163 Thanks to @pnthach95

v0.6.3

21 Sep 03:45

Choose a tag to compare

  • Remove fixed cmake version from build.gradle

v0.6.2

21 Sep 03:43

Choose a tag to compare

  • Fix build failing on App Center, App Circle & Gitlab etc. #160
  • Simplify cmake build

v0.6.1

18 Sep 14:34

Choose a tag to compare

  • Trigger useMMKVStorage change when removeItem is called
  • move getAllMMKVInstanceIDs and getCurrentMMKVInstanceIDs to module level
  • hasKey functions in indexer are now synchronous
  • Allow changing when key and/or storage in useMMKVStorage hook at runtime
  • Add clearMemoryCache function
  • Add getKey function to get encryption key of current MMKV instance
  • Prevent a possible crash when sending incorrect parameters to create function.
  • Do not recompile jsi.cpp from source on Android
  • Now you can set a defaultValue for useMMKVStorage hook.
  • Fix a null exception during migration if value for a key was null
  • Fix numerous build issues on Android such as #155
  • Fix setValue not stable in useMMKVStorage hook #157
  • Fix value type of useMMKVStorage hook could not be changed after it was deleted.
  • Refactor and simplify some parts of the library
  • Update MMKV to 1.2.10

What's new

Transactions
Listen to a value's lifecycle and mutate it on the go. Transactions lets you register lifecycle functions with your storage instance such as onwrite, beforewrite, onread, ondelete. This allows for a better and more managed control over the storage and also let's you build custom indexes with a few lines of code. Refer to #104 issue more detail on this feature.

storage.transactions.register("object","onwrite",(key,value) => {
  //do something
})

Remember that these are not events but functions. If you register the same type of function twice, the later will take precedence.

useIndex
A hook that will take an array of keys and returns an array of values for those keys. This is supposed to work in combination with Transactions. When you have build your custom index, you will need an easy and quick way to load values for your index. useIndex hook actively listens to all read/write changes and updates the values accordingly.

const [posts, update,remove] = useIndex(postsIndex,"object",storage);

v0.6.0

09 Jun 04:45

Choose a tag to compare

Fixed

  1. Null exception while migrating if value for key is null
  2. create function not imported correctly.
  3. Trigger useMMKVStorage change when removeItem is called Thanks @frw
  4. improved types definition for useMMKVStorage hook Thanks @Thanaen

v0.5.9

27 May 08:03

Choose a tag to compare

What's new

  1. The library now exports a simple create function which you can use to create a useMMKVStorage hook.
  2. The useMMKVStorage hook now supports setter functions. #98 Thanks to @SaltedBlowfish

What's fixed

  1. useMMKVStorage return value if it exists on init #105 by @vokhuyetOz
  2. Minor fixes in the docs.

v0.5.8

07 May 10:47

Choose a tag to compare

  1. Fixed unable to access storage after calling clearStore #95

v0.5.7

30 Apr 07:05

Choose a tag to compare

  1. Fix return type on useMMKVStorage hook to pass ts typecheck script #92 @mateosilguero & @mmapplebeck
  2. Removed console.log from useMMKVStorage hook
  3. Convert removeItem & clearStore methods to sync.

v0.5.6

28 Apr 14:49

Choose a tag to compare

Fixed build failing on android #91

v0.5.5

27 Apr 18:45

Choose a tag to compare

Introducing useMMKVStorage Hook 🎉

Thanks to the power of JSI, we now have our very own useMMKVStorage Hook. Think of it like a persisted state that will always write every change in storage and update your app UI instantly. It doesn't matter if you reload the app or restart it. Here's a small demo:

Import MMKVStorage and useMMKVStorage Hook.

import MMKVStorage, { useMMKVStorage } from "react-native-mmkv-storage";

Initialize the MMKVStorage instance.

const MMKV = new MMKVStorage.Loader().initialize();

Next, in our component we are going to register our hook.

const App = () => {
  const [user, setUser] = useMMKVStorage("user", MMKV);

  return (
    <View>
      <Text>{user}</Text>
    </View>
  );
};

To update value of "user" in storage and your App component will automatically rerender.

setUser("andrew");


// or you can do this too anywhere in the app:
MMKV.setString("user", "andrew");

Head over to the docs for complete usage.

What's Fixed:

  1. Fix #64 especially on iOS on reloading app when MMKV was not registered on JSI
  2. Updated docs to correctly install library along with react-native-reanimated. #89 #90 @r0b0t3d
  3. All hasKey functions in the indexer are now synchronous