Skip to content

Commit b272134

Browse files
committed
Fix Typings for RadioGroup and RadioButton
1 parent 35433cc commit b272134

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

generatedTypes/components/radioButton/RadioButton.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react';
22
import { TextStyle, ImageSourcePropType, ImageStyle, ViewProps } from 'react-native';
3-
import { BaseComponentInjectedProps, ForwardRefInjectedProps } from '../../commons/new';
43
import { RadioGroupContextPropTypes } from './RadioGroupContext';
5-
export declare type RadioButtonPropTypes = RadioGroupContextPropTypes & BaseComponentInjectedProps & ForwardRefInjectedProps & ViewProps & {
4+
export declare type RadioButtonPropTypes = RadioGroupContextPropTypes & ViewProps & {
65
/**
76
* The identifier value of the radio button. must be different than other RadioButtons in the same group
87
*/

generatedTypes/components/radioButton/RadioGroup.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
2-
import { BaseComponentInjectedProps, ForwardRefInjectedProps } from '../../commons/new';
3-
export declare type RadioGroupPropTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & {
2+
export declare type RadioGroupPropTypes = {
43
/**
54
* The initial value of the selected radio button
65
*/

src/components/radioButton/RadioButton.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {RadioGroupContextPropTypes} from './RadioGroupContext';
2323
const DEFAULT_SIZE = 24;
2424
const DEFAULT_COLOR = Colors.blue30;
2525

26-
export type RadioButtonPropTypes = RadioGroupContextPropTypes & BaseComponentInjectedProps & ForwardRefInjectedProps & ViewProps & {
26+
export type RadioButtonPropTypes = RadioGroupContextPropTypes & ViewProps & {
2727
/**
2828
* The identifier value of the radio button. must be different than other RadioButtons in the same group
2929
*/
@@ -79,10 +79,12 @@ interface RadioButtonState {
7979
scaleAnimationValue: Animated.Value;
8080
}
8181

82+
type Props = RadioButtonPropTypes & BaseComponentInjectedProps & ForwardRefInjectedProps;
83+
8284
/**
8385
* A Radio Button component, should be wrapped inside a RadioGroup
8486
*/
85-
class RadioButton extends PureComponent<RadioButtonPropTypes, RadioButtonState> {
87+
class RadioButton extends PureComponent<Props, RadioButtonState> {
8688
static displayName = 'RadioButton';
8789

8890
static defaultProps = {
@@ -95,7 +97,7 @@ class RadioButton extends PureComponent<RadioButtonPropTypes, RadioButtonState>
9597
image: StyleProp<ImageStyle>;
9698
};
9799

98-
constructor(props: RadioButtonPropTypes) {
100+
constructor(props: Props) {
99101
super(props);
100102
this.styles = createStyles(props);
101103
this.state = {
@@ -108,7 +110,7 @@ class RadioButton extends PureComponent<RadioButtonPropTypes, RadioButtonState>
108110
this.animate();
109111
}
110112

111-
componentDidUpdate(prevProps: RadioButtonPropTypes) {
113+
componentDidUpdate(prevProps: Props) {
112114
if (prevProps.selected !== this.props.selected) {
113115
this.animate();
114116
}

src/components/radioButton/RadioGroup.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {asBaseComponent, forwardRef, BaseComponentInjectedProps, ForwardRefInjec
44
import View from '../view';
55
import RadioGroupContext from './RadioGroupContext';
66

7-
export type RadioGroupPropTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & {
7+
export type RadioGroupPropTypes = {
88
/**
99
* The initial value of the selected radio button
1010
*/
@@ -19,21 +19,23 @@ interface RadioGroupState {
1919
value?: RadioGroupPropTypes['initialValue'];
2020
}
2121

22+
type Props = RadioGroupPropTypes & BaseComponentInjectedProps & ForwardRefInjectedProps;
23+
2224
/**
2325
* Wrap a group of Radio Buttons to automatically control their selection
2426
*/
25-
class RadioGroup extends PureComponent<RadioGroupPropTypes, RadioGroupState> {
27+
class RadioGroup extends PureComponent<Props, RadioGroupState> {
2628
static displayName = 'RadioGroup';
2729

28-
constructor(props: RadioGroupPropTypes) {
30+
constructor(props: Props) {
2931
super(props);
3032

3133
this.state = {
3234
value: props.initialValue
3335
};
3436
}
3537

36-
UNSAFE_componentWillReceiveProps(nextProps: RadioGroupPropTypes) {
38+
UNSAFE_componentWillReceiveProps(nextProps: Props) {
3739
if (this.props.initialValue !== nextProps.initialValue) {
3840
this.setState({value: nextProps.initialValue});
3941
}

0 commit comments

Comments
 (0)