From edf780592212d3e8e11a2542034895078624e403 Mon Sep 17 00:00:00 2001 From: Tom Xu Date: Tue, 2 Jun 2020 14:12:04 +0800 Subject: [PATCH] fix: Radio.Group options: Element type is invalid (#24666) --- components/radio/index.tsx | 9 ++++++++- components/radio/radio.tsx | 13 ++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/components/radio/index.tsx b/components/radio/index.tsx index e4d519283b..c0f633856e 100644 --- a/components/radio/index.tsx +++ b/components/radio/index.tsx @@ -1,9 +1,16 @@ -import Radio from './radio'; +import InternalRadio from './radio'; import Group from './group'; import Button from './radioButton'; +import { RadioProps } from './interface'; export * from './interface'; +interface CompoundedComponent + extends React.ForwardRefExoticComponent> { + Group: typeof Group; + Button: typeof Group; +} +const Radio = InternalRadio as CompoundedComponent; Radio.Button = Button; Radio.Group = Group; export { Button, Group }; diff --git a/components/radio/radio.tsx b/components/radio/radio.tsx index 2fd6c2c766..a80ddfccd6 100644 --- a/components/radio/radio.tsx +++ b/components/radio/radio.tsx @@ -1,19 +1,11 @@ import * as React from 'react'; import RcCheckbox from 'rc-checkbox'; import classNames from 'classnames'; -import RadioGroup from './group'; -import RadioButton from './radioButton'; import { RadioProps, RadioChangeEvent } from './interface'; import { ConfigContext } from '../config-provider'; import RadioGroupContext from './context'; import { composeRef } from '../_util/ref'; -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { - Group: typeof RadioGroup; - Button: typeof RadioButton; -} - const InternalRadio: React.ForwardRefRenderFunction = (props, ref) => { const context = React.useContext(RadioGroupContext); const { getPrefixCls, direction } = React.useContext(ConfigContext); @@ -60,10 +52,9 @@ const InternalRadio: React.ForwardRefRenderFunction = (prop ); }; -const Radio = React.forwardRef(InternalRadio) as CompoundedComponent; +const Radio = React.forwardRef(InternalRadio); Radio.displayName = 'Radio'; -Radio.Group = RadioGroup; -Radio.Button = RadioButton; + Radio.defaultProps = { type: 'radio', };