Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: useMMKVStorage nextValue as a function #247

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/src/hooks/useMMKV.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import MMKVInstance from '../mmkvinstance';
* @param storage The storage instance
* @returns `useMMKVStorage` hook
*/
export declare const create: <T>(storage: MMKVInstance) => (key: string, defaultValue: any) => [value: T | null | undefined, setValue: (value: T) => void];
export declare const create: <T>(storage: MMKVInstance) => (key: string, defaultValue: any) => [value: T | null | undefined, setValue: (value: T | ((prevValue: T | null | undefined) => T)) => void];
/**
*
* useMMKVStorage Hook is like a persisted state that will always write every change in storage and update your app UI instantly.
Expand All @@ -46,5 +46,5 @@ export declare const create: <T>(storage: MMKVInstance) => (key: string, default
*
* @returns `[value,setValue]`
*/
export declare const useMMKVStorage: <T>(key: string, storage: MMKVInstance, defaultValue: any) => [value: T | null | undefined, setValue: (value: T) => void];
export declare const useMMKVStorage: <T>(key: string, storage: MMKVInstance, defaultValue: any) => [value: T | null | undefined, setValue: (value: T | ((prevValue: T | null | undefined) => T)) => void];
//# sourceMappingURL=useMMKV.d.ts.map
2 changes: 1 addition & 1 deletion dist/src/hooks/useMMKV.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/hooks/useMMKV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const useMMKVStorage = <T>(
key: string,
storage: MMKVInstance,
defaultValue: any
): [value: T | null | undefined, setValue: (value: T) => void] => {
): [value: T | null | undefined, setValue: (value: T | ((prevValue: T | null | undefined) => T)) => void] => {
const getValue = useCallback(getInitialValue(key, storage, 'value'), [key, storage]);
const getValueType = useCallback(getInitialValue(key, storage, 'type'), [key, storage]);

Expand Down