Skip to content

Commit

Permalink
Merge pull request #31012 from kubabutkiewicz/ts-migration/FormElemen…
Browse files Browse the repository at this point in the history
…t/component

[TS migration] Migrate 'FormElement.js' component to TypeScript
  • Loading branch information
mountiny authored Nov 16, 2023
2 parents db95b8f + 2571645 commit a615c41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
16 changes: 0 additions & 16 deletions src/components/FormElement.js

This file was deleted.

18 changes: 18 additions & 0 deletions src/components/FormElement.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, {ForwardedRef, forwardRef} from 'react';
import {View, ViewProps} from 'react-native';
import * as ComponentUtils from '@libs/ComponentUtils';

function FormElement(props: ViewProps, ref: ForwardedRef<View>) {
return (
<View
role={ComponentUtils.ACCESSIBILITY_ROLE_FORM}
ref={ref}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
/>
);
}

FormElement.displayName = 'FormElement';

export default forwardRef(FormElement);
3 changes: 2 additions & 1 deletion src/components/SignInPageForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useEffect, useRef} from 'react';
import {View} from 'react-native';
import FormElement from '@components/FormElement';
import SignInPageFormProps from './types';

Expand All @@ -9,7 +10,7 @@ const preventFormDefault = (event: SubmitEvent) => {
};

function SignInPageForm(props: SignInPageFormProps) {
const form = useRef<HTMLFormElement>(null);
const form = useRef<HTMLFormElement & View>(null);

useEffect(() => {
const formCurrent = form.current;
Expand Down

0 comments on commit a615c41

Please sign in to comment.