@bouko/react 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,6 +3,7 @@ export declare const useForm: <T>(init: T) => {
|
|
|
3
3
|
data: T;
|
|
4
4
|
update: import("react").Dispatch<import("react").SetStateAction<T>>;
|
|
5
5
|
clear: () => void;
|
|
6
|
+
setField: <T_1>(name: string, value: T_1) => void;
|
|
6
7
|
};
|
|
7
8
|
export declare const setField: <T>(update: SetState<T>, id: string, value: unknown) => void;
|
|
8
9
|
export declare const parseData: <T extends Record<string, unknown>>(data: T) => T;
|
|
@@ -8,7 +8,8 @@ export const useForm = (init) => {
|
|
|
8
8
|
return {
|
|
9
9
|
data,
|
|
10
10
|
update: setData,
|
|
11
|
-
clear: () => setData(initial)
|
|
11
|
+
clear: () => setData(initial),
|
|
12
|
+
setField: (name, value) => setField(setData, name, value)
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
export const setField = (update, id, value) => update(prev => ({
|