Skip to content

Commit bfdb56e

Browse files
authored
[React] Use updater function in setData in useForm hook (#1859)
1 parent f47d3c4 commit bfdb56e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react/src/useForm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export default function useForm<TForm extends FormDataType>(
170170
data,
171171
setData(keyOrData: keyof TForm | Function | TForm, maybeValue?: TForm[keyof TForm]) {
172172
if (typeof keyOrData === 'string') {
173-
setData({ ...data, [keyOrData]: maybeValue })
173+
setData((data) => ({ ...data, [keyOrData]: maybeValue }))
174174
} else if (typeof keyOrData === 'function') {
175175
setData((data) => keyOrData(data))
176176
} else {

0 commit comments

Comments
 (0)