Skip to content

Commit

Permalink
fix(components-rn): use displayName (#11547)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqingchen authored Mar 31, 2022
1 parent 904e9c7 commit 37289a9
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { noop } from '../../utils'
import { CheckboxGroupProps, EventOnChange, ValueProps } from './PropsType'

class _CheckboxGroup extends React.Component<CheckboxGroupProps> {
static displayName = '_CheckboxGroup'

values: ValueProps[] = []
tmpIndex = 0

Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components-rn/src/components/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _Form extends React.Component<FormProps> {
// onChange: _CheckboxGroup _RadioGroup _Switch _Slider _Picker
// onBlur: _Input _Textarea
// @ts-ignore
const childTypeName = child.type && child.type.name
const childTypeName = child.type && child.type.displayName
const childPropsName = child.props.name
const valueChangeCbName = childTypeName === '_Input' || childTypeName === '_Textarea' ? 'onBlur' : 'onChange'
const tmpProps = { ...child.props }
Expand Down Expand Up @@ -61,7 +61,7 @@ class _Form extends React.Component<FormProps> {

deppDiveIntoChildren = (children: React.ReactNode): React.ReactNode => {
const result = React.Children.toArray(children).map((child: any) => {
const childTypeName = child.type && child.type.name
const childTypeName = child.type && child.type.displayName
if (!child.type) return child
if (childTypeName === '_Button' && ['submit', 'reset'].indexOf(child.props.formType) >= 0) {
const onClick = child.props.onClick || noop
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components-rn/src/components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const keyboardTypeMap: { [key: string]: string } = {
// }

class _Input extends React.Component<InputProps, InputState> {
static displayName = '_Input'
static defaultProps = {
type: 'text',
maxlength: 140,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import DateSelector from './date'
import RegionSelector from './region'

export default class _Picker extends React.Component<any> {
static displayName = '_Picker'
static defaultProps = {
mode: 'selector',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { noop } from '../../utils'
import { RadioGroupProps, RadioGroupState, EventOnChange } from './PropsType'

class _RadioGroup extends React.Component<RadioGroupProps, RadioGroupState> {
static displayName = '_RadioGroup'
state: RadioGroupState = {
checkedValue: undefined
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import styles from './styles'
import { SliderProps, SliderState } from './PropsType'

class _Slider extends React.Component<SliderProps, SliderState> {
static displayName = '_Slider'
static defaultProps = {
min: 0,
max: 100,
Expand Down

0 comments on commit 37289a9

Please sign in to comment.