From d57a2acd87f8ed50c135da58dd89b841aff23e3c Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 30 Aug 2020 15:10:11 +0800 Subject: [PATCH] perf: update tree --- antdv-demo | 2 +- components/vc-tree/src/Tree.jsx | 12 ++++++++---- examples/App.vue | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/antdv-demo b/antdv-demo index 83ab203d1..5a00801c5 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit 83ab203d1ab9861132f6efd1e74015507c0e45f6 +Subproject commit 5a00801c5012248ce32d8ed7a4164da3a5fde90f diff --git a/components/vc-tree/src/Tree.jsx b/components/vc-tree/src/Tree.jsx index eba40c809..189093752 100644 --- a/components/vc-tree/src/Tree.jsx +++ b/components/vc-tree/src/Tree.jsx @@ -4,6 +4,7 @@ import warning from 'warning'; import { hasProp, initDefaultProps, getOptionProps, getSlot } from '../../_util/props-util'; import { cloneElement } from '../../_util/vnode'; import BaseMixin from '../../_util/BaseMixin'; +import syncWatch from '../../_util/syncWatch'; import { convertTreeToEntities, convertDataToTree, @@ -30,8 +31,11 @@ import { function getWatch(keys = []) { const watch = {}; keys.forEach(k => { - watch[k] = function() { - this.needSyncKeys[k] = true; + watch[k] = { + handler() { + this.needSyncKeys[k] = true; + }, + flush: 'sync', }; }); return watch; @@ -149,10 +153,10 @@ const Tree = { 'checkedKeys', 'loadedKeys', ]), - __propsSymbol__() { + __propsSymbol__: syncWatch(function() { this.setState(this.getDerivedState(getOptionProps(this), this.$data)); this.needSyncKeys = {}; - }, + }), }, methods: { diff --git a/examples/App.vue b/examples/App.vue index b67493837..e9fa21a75 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -15,7 +15,7 @@ Use Drawer to quickly preview details of an object, such as those in a list.