@@ -22,6 +22,7 @@ export type RadioGroupProps = ViewProps & {
22
22
export type RadioGroupPropTypes = RadioGroupProps ; //TODO: remove after ComponentPropTypes deprecation;
23
23
24
24
interface RadioGroupState {
25
+ initialValue ?: RadioGroupProps [ 'initialValue' ] ;
25
26
value ?: RadioGroupProps [ 'initialValue' ] ;
26
27
}
27
28
@@ -39,28 +40,20 @@ class RadioGroup extends PureComponent<Props, RadioGroupState> {
39
40
super ( props ) ;
40
41
41
42
this . state = {
43
+ initialValue : props . initialValue ,
42
44
value : props . initialValue
43
45
} ;
44
46
}
45
47
46
- static getUpdatedState = (
47
- nextProps : Props ,
48
- prevState : RadioGroupState
49
- ) : RadioGroupState | null => {
50
- const { value} = prevState ;
51
- const { initialValue} = nextProps ;
52
-
53
- if ( _ . isUndefined ( nextProps . initialValue ) || value === initialValue ) {
54
- return null ;
48
+ static getDerivedStateFromProps : GetDerivedStateFromProps < Props , RadioGroupState > = ( props , state ) => {
49
+ if ( state . initialValue !== props . initialValue ) {
50
+ return {
51
+ initialValue : props . initialValue ,
52
+ value : props . initialValue
53
+ } ;
55
54
}
56
55
57
- return {
58
- value : initialValue
59
- } ;
60
- } ;
61
-
62
- static getDerivedStateFromProps : GetDerivedStateFromProps < Props , RadioGroupState > = ( props , state ) => {
63
- return RadioGroup . getUpdatedState ( props , state ) ;
56
+ return null ;
64
57
}
65
58
66
59
getContextProviderValue ( ) {
0 commit comments