File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 1
- import { useEffect } from 'react' ;
1
+ import { useEffect , MutableRefObject } from 'react' ;
2
2
3
- // Usage: useSyncFormTranslations(formRef, language)
4
- // This hook ensures that form values are preserved when the language changes.
5
- // Pass a ref to the form instance and the current language as arguments.
6
- const useSyncFormTranslations = ( formRef , language ) => {
3
+ export interface FormLike {
4
+ getState ( ) : { values : Record < string , unknown > } ;
5
+ reset ( ) : void ;
6
+ change ( field : string , value : unknown ) : void ;
7
+ }
8
+
9
+ /**
10
+ * This hook ensures that form values are preserved when the language changes.
11
+ * @param formRef
12
+ * @param language
13
+ */
14
+ const useSyncFormTranslations = (
15
+ formRef : MutableRefObject < FormLike > ,
16
+ language : string
17
+ ) => {
7
18
useEffect ( ( ) => {
8
19
const form = formRef . current ;
9
20
if ( ! form ) return ;
You can’t perform that action at this time.
0 commit comments