This repository was archived by the owner on Dec 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
packages/react-select/src Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " react-select-oss " : patch
3
+ ---
4
+
5
+ Remove UNSAFE React methods from Creatable
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ export const makeCreatableSelect = <C: {}>(
101
101
options : options ,
102
102
} ;
103
103
}
104
- UNSAFE_componentWillReceiveProps ( nextProps : CreatableProps & C ) {
104
+ static getDerivedStateFromProps ( props : CreatableProps & C ) {
105
105
const {
106
106
allowCreateWhileLoading,
107
107
createOptionPosition,
@@ -111,23 +111,20 @@ export const makeCreatableSelect = <C: {}>(
111
111
isLoading,
112
112
isValidNewOption,
113
113
value,
114
- } = nextProps ;
115
- const options = nextProps . options || [ ] ;
116
- let { newOption } = this . state ;
117
- if ( isValidNewOption ( inputValue , cleanValue ( value ) , options ) ) {
118
- newOption = getNewOptionData ( inputValue , formatCreateLabel ( inputValue ) ) ;
119
- } else {
120
- newOption = undefined ;
121
- }
122
- this . setState ( {
114
+ } = props ;
115
+ const options = props . options || [ ] ;
116
+ const newOption = isValidNewOption ( inputValue , cleanValue ( value ) , options )
117
+ ? getNewOptionData ( inputValue , formatCreateLabel ( inputValue ) )
118
+ : undefined ;
119
+ return {
123
120
newOption : newOption ,
124
121
options :
125
122
( allowCreateWhileLoading || ! isLoading ) && newOption
126
123
? createOptionPosition === 'first'
127
124
? [ newOption , ...options ]
128
125
: [ ...options , newOption ]
129
126
: options ,
130
- } ) ;
127
+ } ;
131
128
}
132
129
onChange = ( newValue : ValueType , actionMeta : ActionMeta ) => {
133
130
const {
You can’t perform that action at this time.
0 commit comments