Skip to content

Commit 1e19619

Browse files
authored
fix: replace useForm with useFormState (#138)
1 parent faf3e8c commit 1e19619

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/lib/core/components/Form/hooks/useStore.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import React from 'react';
22

33
import _ from 'lodash';
4-
import {useForm} from 'react-final-form';
4+
import {useFormState} from 'react-final-form';
55

66
import {DynamicFieldStore, FieldObjectValue, FieldValue, ValidateError} from '../types';
77
import {transformArrIn} from '../utils';
88

99
export const useStore = (name: string) => {
10-
const form = useForm();
10+
const formState = useFormState();
1111
const firstRenderRef = React.useRef(true);
1212
const [store, setStore] = React.useState<DynamicFieldStore>(() => {
1313
const values: FieldObjectValue = transformArrIn({
14-
[name]: _.get(form.getState().values, name),
14+
[name]: _.get(formState.values, name),
1515
});
1616

1717
const initialValue = transformArrIn({
18-
[name]: _.get(form.getState().initialValues, name),
18+
[name]: _.get(formState.initialValues, name),
1919
});
2020

2121
return {
@@ -26,7 +26,7 @@ export const useStore = (name: string) => {
2626
};
2727
});
2828

29-
const submitFailed = form.getState().submitFailed;
29+
const submitFailed = formState.submitFailed;
3030

3131
const tools = React.useMemo(
3232
() => ({
@@ -54,11 +54,11 @@ export const useStore = (name: string) => {
5454
React.useEffect(() => {
5555
if (!firstRenderRef.current) {
5656
const values: FieldObjectValue = transformArrIn({
57-
[name]: _.get(form.getState().values, name),
57+
[name]: _.get(formState.values, name),
5858
});
5959

6060
const initialValue = transformArrIn({
61-
[name]: _.get(form.getState().initialValues, name),
61+
[name]: _.get(formState.initialValues, name),
6262
});
6363

6464
setStore({

0 commit comments

Comments
 (0)