Skip to content

Commit d57a2ac

Browse files
author
undefined
committed
perf: update tree
1 parent 3d17d5f commit d57a2ac

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

antdv-demo

components/vc-tree/src/Tree.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import warning from 'warning';
44
import { hasProp, initDefaultProps, getOptionProps, getSlot } from '../../_util/props-util';
55
import { cloneElement } from '../../_util/vnode';
66
import BaseMixin from '../../_util/BaseMixin';
7+
import syncWatch from '../../_util/syncWatch';
78
import {
89
convertTreeToEntities,
910
convertDataToTree,
@@ -30,8 +31,11 @@ import {
3031
function getWatch(keys = []) {
3132
const watch = {};
3233
keys.forEach(k => {
33-
watch[k] = function() {
34-
this.needSyncKeys[k] = true;
34+
watch[k] = {
35+
handler() {
36+
this.needSyncKeys[k] = true;
37+
},
38+
flush: 'sync',
3539
};
3640
});
3741
return watch;
@@ -149,10 +153,10 @@ const Tree = {
149153
'checkedKeys',
150154
'loadedKeys',
151155
]),
152-
__propsSymbol__() {
156+
__propsSymbol__: syncWatch(function() {
153157
this.setState(this.getDerivedState(getOptionProps(this), this.$data));
154158
this.needSyncKeys = {};
155-
},
159+
}),
156160
},
157161

158162
methods: {

examples/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Use Drawer to quickly preview details of an object, such as those in a list.
1515
</div>
1616
</template>
1717
<script>
18-
import demo from '../antdv-demo/docs/transfer/demo/basic.md';
18+
import demo from '../antdv-demo/docs/tree/demo';
1919
export default {
2020
components: {
2121
demo,

0 commit comments

Comments
 (0)