Skip to content

Commit af4aea2

Browse files
authored
hoist static members in asRadioGroupChild HOC (#784)
1 parent 792c643 commit af4aea2

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

generatedTypes/components/radioButton/RadioButton.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { TextStyle, ImageStyle } from 'react-native';
2+
import { TextStyle, ImageSourcePropType, ImageStyle } from 'react-native';
33
interface RadioButtonPropTypes {
44
/**
55
* The identifier value of the radio button. must be different than other RadioButtons in the same group
@@ -40,7 +40,7 @@ interface RadioButtonPropTypes {
4040
/**
4141
* Icon image source
4242
*/
43-
iconSource?: object | number;
43+
iconSource?: ImageSourcePropType;
4444
/**
4545
* Icon image style
4646
*/

src/components/radioButton/RadioButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,4 @@ function createStyles(props: Props) {
280280
});
281281
}
282282

283-
export default asRadioGroupChild(asBaseComponent<RadioButtonPropTypes>(forwardRef(RadioButton)));
283+
export default asBaseComponent<RadioButtonPropTypes>(forwardRef(asRadioGroupChild(RadioButton)));

src/components/radioButton/asRadioGroupChild.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, {Component} from 'react';
2+
// @ts-ignore
3+
import hoistStatics from 'hoist-non-react-statics';
24
import RadioGroupContext from './RadioGroupContext';
35

46
interface RadioGroupChildPropTypes {
@@ -16,6 +18,8 @@ type PropTypes = RadioGroupChildPropTypes;
1618

1719
export default function asRadioGroupChild(WrappedComponent: React.ComponentType<any>) {
1820
class RadioGroupChild extends Component<PropTypes> {
21+
static displayName: string | undefined;
22+
1923
render() {
2024
const {value: buttonValue, selected} = this.props;
2125
return (
@@ -33,5 +37,8 @@ export default function asRadioGroupChild(WrappedComponent: React.ComponentType<
3337
}
3438
}
3539

40+
hoistStatics(RadioGroupChild, WrappedComponent);
41+
RadioGroupChild.displayName = WrappedComponent.displayName;
42+
3643
return RadioGroupChild as any;
3744
}

0 commit comments

Comments
 (0)