Skip to content

Commit 1b97e49

Browse files
felixmoshlayershifter
authored andcommitted
chore(FormRadio): use React.forwardRef() (#4406)
1 parent 9738a3e commit 1b97e49

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/collections/Form/FormRadio.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 Radio
1212
*/
13-
function FormRadio(props) {
13+
const FormRadio = React.forwardRef(function (props, ref) {
1414
const { control } = props
1515
const rest = getUnhandledProps(FormRadio, props)
1616
const ElementType = getElementType(FormRadio, props)
1717

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

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('FormRadio', () => {
88
common.isConformant(FormRadio, {
99
ignoredTypingsProps: ['type'],
1010
})
11+
common.forwardsRef(FormRadio, { tagName: 'input' })
1112

1213
it('renders a FormField with a Radio control', () => {
1314
shallow(<FormRadio />)

0 commit comments

Comments
 (0)