Skip to content

Commit 32a3925

Browse files
authored
Merge pull request #272 from sendbird/fix/support-mmkv4
[CLNP-7725] feat: support MMKV version 4.0 or higher
2 parents f2c136c + 19c4609 commit 32a3925

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/uikit-react-native/src/libs/InternalLocalCacheStorage.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ export default class InternalLocalCacheStorage implements AsyncLocalCacheStorage
4242

4343
async removeItem(key: string) {
4444
if (this._mmkv) {
45-
this._mmkv.delete(key);
45+
// Support both v3.x (delete) and v4.x (remove) APIs for backward compatibility
46+
if (this._mmkv.delete) {
47+
this._mmkv.delete(key);
48+
} else if (this._mmkv.remove) {
49+
this._mmkv.remove(key);
50+
}
4651
} else if (this._async) {
4752
return this._async.removeItem(key);
4853
}

packages/uikit-react-native/src/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export interface AsyncLocalCacheStorage {
1818
multiRemove?(keys: string[]): Promise<void>;
1919
}
2020

21-
export type MMKVLocalCacheStorage = Pick<MMKV, 'getString' | 'set' | 'delete' | 'getAllKeys'>;
21+
export type MMKVLocalCacheStorage = Pick<MMKV, 'getString' | 'set' | 'getAllKeys'> & {
22+
// Support both v3.x (delete) and v4.x (remove) APIs for backward compatibility
23+
delete?: (key: string) => void;
24+
remove?: (key: string) => void;
25+
};
2226

2327
export type ErrorBoundaryProps = { error: Error; errorInfo: ErrorInfo; reset: () => void };
2428

0 commit comments

Comments
 (0)