Skip to content

Commit

Permalink
chore(FormRadio): use React.forwardRef() (#4406)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh authored and layershifter committed Dec 13, 2022
1 parent 9738a3e commit 1b97e49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/collections/Form/FormRadio.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import FormField from './FormField'
* @see Form
* @see Radio
*/
function FormRadio(props) {
const FormRadio = React.forwardRef(function (props, ref) {
const { control } = props
const rest = getUnhandledProps(FormRadio, props)
const ElementType = getElementType(FormRadio, props)

return <ElementType {...rest} control={control} />
}
return <ElementType {...rest} control={control} ref={ref} />
})

FormRadio.displayName = 'FormRadio'
FormRadio.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
Expand Down
1 change: 1 addition & 0 deletions test/specs/collections/Form/FormRadio-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('FormRadio', () => {
common.isConformant(FormRadio, {
ignoredTypingsProps: ['type'],
})
common.forwardsRef(FormRadio, { tagName: 'input' })

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

0 comments on commit 1b97e49

Please sign in to comment.