Skip to content

Commit e8750ed

Browse files
committed
client/modules/User/components/LoginForm: update with types & update useSyncFormTranslations to handle null formRef
1 parent 62cee39 commit e8750ed

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

client/common/useSyncFormTranslations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export interface FormLike {
1212
* @param language
1313
*/
1414
export const useSyncFormTranslations = (
15-
formRef: MutableRefObject<FormLike>,
15+
formRef: MutableRefObject<FormLike | null>,
1616
language: string
1717
) => {
1818
useEffect(() => {
19-
const form = formRef.current;
19+
const form = formRef?.current;
2020
if (!form) return;
2121

2222
const { values } = form.getState();

client/modules/User/components/LoginForm.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai';
66
import { Button, ButtonTypes } from '../../../common/Button';
77
import { validateLogin } from '../../../utils/reduxFormUtils';
88
import { validateAndLoginUser } from '../actions';
9-
import { useSyncFormTranslations } from '../../../common/useSyncFormTranslations';
9+
import {
10+
FormLike,
11+
useSyncFormTranslations
12+
} from '../../../common/useSyncFormTranslations';
13+
import type { LoginForm as LoginFormType } from '../../../utils/reduxFormUtils';
1014

1115
export function LoginForm() {
1216
const { t, i18n } = useTranslation();
1317

1418
const dispatch = useDispatch();
15-
function onSubmit(formProps) {
19+
function onSubmit(formProps: LoginFormType) {
1620
return dispatch(validateAndLoginUser(formProps));
1721
}
1822
const [showPassword, setShowPassword] = useState(false);
19-
const formRef = useRef(null);
23+
const formRef = useRef<FormLike | null>(null);
2024

2125
const handleVisibility = () => {
2226
setShowPassword(!showPassword);

0 commit comments

Comments
 (0)