File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,4 @@ const appRoot = document.createElement('div');
9
9
10
10
appRoot . id = 'app' ;
11
11
document . body . appendChild ( appRoot ) ;
12
- ReactDOM . render ( < App /> , appRoot ) ;
12
+ ReactDOM . render ( < React . StrictMode > < App /> </ React . StrictMode > , appRoot ) ;
Original file line number Diff line number Diff line change @@ -39,30 +39,26 @@ export class DebounceInput extends React.PureComponent {
39
39
constructor ( props ) {
40
40
super ( props ) ;
41
41
42
- this . state = {
43
- value : props . value || ''
44
- } ;
45
-
46
42
this . isDebouncing = false ;
47
- }
43
+ this . state = { value : props . value || '' } ;
48
44
49
-
50
- // eslint-disable-next-line react/no-deprecated
51
- componentWillMount ( ) {
52
45
const { debounceTimeout} = this . props ;
53
46
this . createNotifier ( debounceTimeout ) ;
54
47
}
55
48
56
49
57
- // eslint-disable-next-line react/no-deprecated
58
- componentWillReceiveProps ( { value, debounceTimeout} ) {
50
+ componentDidUpdate ( prevProps ) {
59
51
if ( this . isDebouncing ) {
60
52
return ;
61
53
}
62
- const { debounceTimeout : oldTimeout } = this . props ;
54
+ const { value, debounceTimeout} = this . props ;
55
+
56
+ const { debounceTimeout : oldTimeout , value : oldValue } = prevProps ;
63
57
const { value : stateValue } = this . state ;
64
58
65
- if ( typeof value !== 'undefined' && stateValue !== value ) {
59
+ if ( typeof value !== 'undefined' && oldValue !== value && stateValue !== value ) {
60
+ // Update state.value if new value passed via props, yep re-render should happen
61
+ // eslint-disable-next-line react/no-did-update-set-state
66
62
this . setState ( { value} ) ;
67
63
}
68
64
if ( debounceTimeout !== oldTimeout ) {
You can’t perform that action at this time.
0 commit comments