Add mmkv v4 support for MMKV dev tools #84
Open
theafolayan wants to merge 5 commits intoexpo:mainfrom
Open
Conversation
Refactor useMMKVDevTools to use createMMKV from v4
Bump version and update dependencies in package.json
vonovak
requested changes
Nov 3, 2025
| { | ||
| "name": "@dev-plugins/react-native-mmkv", | ||
| "version": "0.4.0", | ||
| "version": "0.4.1", |
Contributor
There was a problem hiding this comment.
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; |
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
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 }); |
| on('set', async ({ key, value }) => { | ||
| if (key !== undefined && value !== undefined) { | ||
| storage.set(key, value); | ||
| return true; |
Contributor
There was a problem hiding this comment.
what's the reason to return a boolean?
| subscriptions.push( | ||
| on('remove', async ({ key }) => { | ||
| if (key !== undefined) { | ||
| storage.remove(key); |
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the
@dev-plugins/react-native-mmkvpackage to support the latest versions of its dependencies and aligns the code with breaking changes in thereact-native-mmkvAPI. The main focus is on upgrading toreact-native-mmkvv4 and updating the usage of its API in the codebase.Dependency upgrades:
react-native-mmkvfrom^3.1.0to^4.0.0inpackage.json, and updatedexpoto^54.0.0to ensure compatibility with the latest ecosystem.0.4.0to0.4.1to reflect these changes.Code changes for
react-native-mmkvv4 compatibility:MMKVconstructor with the newcreateMMKVfactory function inuseMMKVDevTools.ts. [1] [2]deletetoremoveto match the new API inreact-native-mmkvv4.