react-form-manage 1.0.8-beta.12 → 1.0.8-beta.14

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.
@@ -267,7 +267,7 @@ function useForm(formNameOrFormInstance) {
267
267
  const formContext = useContext(FormContext);
268
268
  const targetFormName = isNil(formNameOrFormInstance) ? formContext == null ? void 0 : formContext.formName : typeof formNameOrFormInstance === "object" && formNameOrFormInstance !== null ? formNameOrFormInstance.formName : formNameOrFormInstance;
269
269
  const formInstance = useFormStore((state) => {
270
- return Object.values(state.formInstances).find((i) => i.formName === targetFormName);
270
+ return state.formInstances.find((i) => i.formName === targetFormName);
271
271
  });
272
272
  return [formInstance];
273
273
  }
@@ -38,7 +38,7 @@ interface FormStoreState {
38
38
  initialValues: Record<string, any>;
39
39
  formStates: Record<string, any>;
40
40
  cacheData: Record<string, any>;
41
- formInstances: Record<string, FormInstance>;
41
+ formInstances: FormInstance[];
42
42
  submitHistory: Record<string, any[]>;
43
43
  listeners: ListenerItem[];
44
44
  cleanUpStack: CleanUpItem[];
@@ -8,7 +8,7 @@ const createFormStoreSlice = (storeSet, storeGet, api) => ({
8
8
  initialValues: {},
9
9
  formStates: {},
10
10
  cacheData: {},
11
- formInstances: {},
11
+ formInstances: [],
12
12
  submitHistory: {},
13
13
  setData(formName, name, value) {
14
14
  return storeSet(produce((state) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-form-manage",
3
- "version": "1.0.8-beta.12",
3
+ "version": "1.0.8-beta.14",
4
4
  "description": "Lightweight React form management with list and listener support.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -422,9 +422,7 @@ export function useForm<T = any>(
422
422
  : (formNameOrFormInstance as string | undefined);
423
423
 
424
424
  const formInstance = useFormStore((state) => {
425
- return Object.values(state.formInstances).find(
426
- (i) => i.formName === targetFormName,
427
- );
425
+ return state.formInstances.find((i) => i.formName === targetFormName);
428
426
  }) as PublicFormInstance<T> | undefined;
429
427
 
430
428
  return [formInstance];
@@ -44,7 +44,7 @@ interface FormStoreState {
44
44
  initialValues: Record<string, any>;
45
45
  formStates: Record<string, any>;
46
46
  cacheData: Record<string, any>;
47
- formInstances: Record<string, FormInstance>;
47
+ formInstances: FormInstance[];
48
48
  submitHistory: Record<string, any[]>;
49
49
  listeners: ListenerItem[];
50
50
  cleanUpStack: CleanUpItem[];
@@ -59,7 +59,7 @@ const createFormStoreSlice = (storeSet: any, storeGet: any, api: any) => ({
59
59
  initialValues: {},
60
60
  formStates: {},
61
61
  cacheData: {},
62
- formInstances: {},
62
+ formInstances: [],
63
63
  submitHistory: {},
64
64
  setData(formName, name, value) {
65
65
  return storeSet(