Skip to content

v0.5.5

Compare
Choose a tag to compare
@ammarahm-ed ammarahm-ed released this 27 Apr 18:45
· 394 commits to master since this release

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