Commit 9cbab09 1 parent 8d3b25d commit 9cbab09 Copy full SHA for 9cbab09
File tree 2 files changed +309
-249
lines changed
2 files changed +309
-249
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Component , Children } from 'react' ;
2
2
import { findDOMNode } from 'react-dom' ;
3
3
import PropTypes from 'prop-types' ;
4
+ import { polyfill } from 'react-lifecycles-compat' ;
4
5
import cx from 'classnames' ;
5
6
import Icon from '../../icon' ;
6
7
import Checkbox from '../../checkbox' ;
@@ -16,7 +17,7 @@ const isRoot = pos => /^0-(\d)+$/.test(pos);
16
17
/**
17
18
* Tree.Node
18
19
*/
19
- export default class TreeNode extends Component {
20
+ class TreeNode extends Component {
20
21
static propTypes = {
21
22
_key : PropTypes . string ,
22
23
prefix : PropTypes . string ,
@@ -109,19 +110,21 @@ export default class TreeNode extends Component {
109
110
] ) ;
110
111
}
111
112
113
+ static getDerivedStateFromProps ( props ) {
114
+ if ( 'label' in props ) {
115
+ return {
116
+ label : props . label ,
117
+ } ;
118
+ }
119
+
120
+ return null ;
121
+ }
122
+
112
123
componentDidMount ( ) {
113
124
this . itemNode = findDOMNode ( this . refs . node ) ;
114
125
this . setFocus ( ) ;
115
126
}
116
127
117
- componentWillReceiveProps ( nextProps ) {
118
- if ( 'label' in nextProps ) {
119
- this . setState ( {
120
- label : nextProps . label ,
121
- } ) ;
122
- }
123
- }
124
-
125
128
componentDidUpdate ( ) {
126
129
this . setFocus ( ) ;
127
130
}
@@ -593,3 +596,5 @@ export default class TreeNode extends Component {
593
596
) ;
594
597
}
595
598
}
599
+
600
+ export default polyfill ( TreeNode ) ;
You can’t perform that action at this time.
0 commit comments