Skip to content

Commit

Permalink
fix: incorrect return type for hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Feb 13, 2022
1 parent d858b66 commit f94d10f
Show file tree
Hide file tree
Showing 10 changed files with 25,380 additions and 5,458 deletions.
2 changes: 1 addition & 1 deletion dist/src/hooks/useIndex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ import { DataType } from '../types';
*
* @returns `[values, update, remove]`
*/
export declare const useIndex: <T>(keys: string[], type: DataType, storage: API) => ((T | null | undefined)[] | ((key: any, value: any) => void))[];
export declare const useIndex: <T>(keys: string[], type: DataType, storage: API) => [values: (T | null | undefined)[], update: (key: string, value: T) => void, remove: (key: string) => void];
//# sourceMappingURL=useIndex.d.ts.map
2 changes: 1 addition & 1 deletion dist/src/hooks/useIndex.d.ts.map

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

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 API from '../api';
* @param storage The storage instance
* @returns `useMMKVStorage` hook
*/
export declare const create: (storage: API) => (key: string, defaultValue: any) => any[];
export declare const create: <T>(storage: API) => (key: string, defaultValue: any) => [value: T | null | undefined, setValue: (value: 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: (storage: API) => (key: string, defaultValue: any)
*
* @returns `[value,setValue]`
*/
export declare const useMMKVStorage: <T>(key: string, storage: API, defaultValue: any) => any[];
export declare const useMMKVStorage: <T>(key: string, storage: API, defaultValue: any) => [value: T | null | undefined, setValue: (value: 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.

12 changes: 7 additions & 5 deletions dist/src/hooks/useMMKV.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ import { getDataType, getInitialValue } from './functions';
* @param storage The storage instance
* @returns `useMMKVStorage` hook
*/
export var create = function (storage) { return function (key, defaultValue) {
if (!key || typeof key !== 'string' || !storage)
throw new Error('Key and Storage are required parameters.');
return useMMKVStorage(key, storage, defaultValue);
}; };
export var create = function (storage) {
return function (key, defaultValue) {
if (!key || typeof key !== 'string' || !storage)
throw new Error('Key and Storage are required parameters.');
return useMMKVStorage(key, storage, defaultValue);
};
};
/**
*
* useMMKVStorage Hook is like a persisted state that will always write every change in storage and update your app UI instantly.
Expand Down
Loading

1 comment on commit f94d10f

@vercel
Copy link

@vercel vercel bot commented on f94d10f Feb 13, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.