Skip to content

Commit eeffde3

Browse files
authored
chore(FormInput): use React.forwardRef() (#4407)
1 parent 4d28c77 commit eeffde3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/collections/Form/FormInput.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import FormField from './FormField'
1010
* @see Form
1111
* @see Input
1212
*/
13-
function FormInput(props) {
13+
const FormInput = React.forwardRef(function (props, ref) {
1414
const { control } = props
1515
const rest = getUnhandledProps(FormInput, props)
1616
const ElementType = getElementType(FormInput, props)
1717

18-
return <ElementType {...rest} control={control} />
19-
}
18+
return <ElementType {...rest} control={control} ref={ref} />
19+
})
2020

21+
FormInput.displayName = 'FormInput'
2122
FormInput.propTypes = {
2223
/** An element type to render as (string or function). */
2324
as: PropTypes.elementType,

test/specs/collections/Form/FormInput-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('FormInput', () => {
5151
ignoredTypingsProps: ['label', 'error'],
5252
})
5353
common.labelImplementsHtmlForProp(FormInput)
54+
common.forwardsRef(FormInput, { tagName: 'input' })
5455

5556
it('renders a FormField with a Input control', () => {
5657
shallow(<FormInput />)

0 commit comments

Comments
 (0)