Skip to content

Conversation

@theafolayan
Copy link

This pull request updates the @dev-plugins/react-native-mmkv package to support the latest versions of its dependencies and aligns the code with breaking changes in the react-native-mmkv API. The main focus is on upgrading to react-native-mmkv v4 and updating the usage of its API in the codebase.

Dependency upgrades:

  • Upgraded react-native-mmkv from ^3.1.0 to ^4.0.0 in package.json, and updated expo to ^54.0.0 to ensure compatibility with the latest ecosystem.
  • Bumped the package version from 0.4.0 to 0.4.1 to reflect these changes.

Code changes for react-native-mmkv v4 compatibility:

  • Replaced the deprecated MMKV constructor with the new createMMKV factory function in useMMKVDevTools.ts. [1] [2]
  • Updated the storage removal method from delete to remove to match the new API in react-native-mmkv v4.

{
"name": "@dev-plugins/react-native-mmkv",
"version": "0.4.0",
"version": "0.4.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"version": "0.4.1",
"version": "0.4.0",

kindly keep it as it was and we'll see how to bump it

}: {
type Params = {
errorHandler?: (error: Error) => void;
storage?: MMKV;
Copy link
Contributor

@vonovak vonovak Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
storage?: MMKV;
storage: MMKV;

let's make storage required. Then we don't need to worry about how to construct mmkv and the plugin potentially stays compatible with both v3 and v4 (and so on)

} catch (e) {
handleError(e);
}
const n = storage.getNumber?.(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const n = storage.getNumber?.(key);
const n = storage.getNumber(key);

no need for optional here and below?

const result = await listener(params);

client?.sendMessage(`ack:${event}`, { result });
client.sendMessage(`ack:${event}`, { result: result ?? true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why result ?? true

on('set', async ({ key, value }) => {
if (key !== undefined && value !== undefined) {
storage.set(key, value);
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason to return a boolean?

subscriptions.push(
on('remove', async ({ key }) => {
if (key !== undefined) {
storage.remove(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v3 uses the delete method. By calling delete or remove we could stay compatible with both versions.

If that's a problem for some reason, lets target only v4. in which case we need to bump the mmkv entry in peerDependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants