MCPcopy Create free account
hub / github.com/ElemeFE/element-react / componentDidMount

Method componentDidMount

src/tree/Node.jsx:48–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46 }
47
48 componentDidMount(): void {
49 const nodeModel = this.props.nodeModel;
50 const childrenKey = this.props.options.children || 'children';
51
52 const triggerChange = debounce(20, (...args) => {
53 if (this.isDeconstructed) return;
54 this.handleSelectChange.apply(this, args);
55 });
56
57 this.loadHandler = this.enhanceLoad(nodeModel);
58 this.watchers = {
59 [this.idGen.next()]: watchPropertyChange(
60 nodeModel,
61 'indeterminate',
62 value => {
63 triggerChange(nodeModel.checked, value);
64 }
65 ),
66 [this.idGen.next()]: watchPropertyChange(nodeModel, 'checked', value => {
67 triggerChange(value, nodeModel.indeterminate);
68 }),
69 [this.idGen.next()]: watchPropertyChange(nodeModel, 'loading', () => {
70 this.setState({});
71 })
72 };
73
74 if (nodeModel.data != null) {
75 this.watchers[
76 this.idGen.next()
77 ] = watchPropertyChange(nodeModel.data, childrenKey, () => {
78 nodeModel.updateChildren();
79 this.setState({}); //force update view
80 });
81 }
82 }
83
84 componentWillUnmount(): void {
85 this.loadHandler();

Callers

nothing calls this directly

Calls 4

enhanceLoadMethod · 0.95
watchPropertyChangeFunction · 0.90
updateChildrenMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected