@sheinx/hooks 3.9.11-beta.10 → 3.9.11-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -652,15 +652,8 @@ var useTree = function useTree(props) {
652
652
  if (props.datum) return;
653
653
  if (!dataUpdate) return;
654
654
  setData(data);
655
- var nextExpanded = props.expanded || props.defaultExpanded || [];
656
- if (!defaultExpandAll && !(0, _utils.shallowEqual)(nextExpanded, expanded)) {
657
- onExpand(nextExpanded);
658
- updateExpanded(nextExpanded, true);
659
- }
660
- updateInnerCheckStatus();
661
- }, [props.data]);
662
- (0, _react.useEffect)(function () {
663
655
  if (defaultExpandAll) {
656
+ // data 变化后 dataMap 已由 setData 填充,直接收集所有可展开节点
664
657
  var nextExpanded = [];
665
658
  context.dataMap.forEach(function (item, k) {
666
659
  if (item[childrenKey]) {
@@ -669,8 +662,15 @@ var useTree = function useTree(props) {
669
662
  });
670
663
  onExpand(nextExpanded);
671
664
  updateExpanded(nextExpanded, true);
665
+ } else {
666
+ var _nextExpanded = props.expanded || props.defaultExpanded || [];
667
+ if (!(0, _utils.shallowEqual)(_nextExpanded, expanded)) {
668
+ onExpand(_nextExpanded);
669
+ updateExpanded(_nextExpanded, true);
670
+ }
672
671
  }
673
- }, [context.dataMap, props.data]);
672
+ updateInnerCheckStatus();
673
+ }, [props.data]);
674
674
  (0, _react.useEffect)(function () {
675
675
  if (props.datum) return;
676
676
  setValue(value);
@@ -645,15 +645,8 @@ var useTree = function useTree(props) {
645
645
  if (props.datum) return;
646
646
  if (!dataUpdate) return;
647
647
  setData(data);
648
- var nextExpanded = props.expanded || props.defaultExpanded || [];
649
- if (!defaultExpandAll && !shallowEqual(nextExpanded, expanded)) {
650
- onExpand(nextExpanded);
651
- updateExpanded(nextExpanded, true);
652
- }
653
- updateInnerCheckStatus();
654
- }, [props.data]);
655
- useEffect(function () {
656
648
  if (defaultExpandAll) {
649
+ // data 变化后 dataMap 已由 setData 填充,直接收集所有可展开节点
657
650
  var nextExpanded = [];
658
651
  context.dataMap.forEach(function (item, k) {
659
652
  if (item[childrenKey]) {
@@ -662,8 +655,15 @@ var useTree = function useTree(props) {
662
655
  });
663
656
  onExpand(nextExpanded);
664
657
  updateExpanded(nextExpanded, true);
658
+ } else {
659
+ var _nextExpanded = props.expanded || props.defaultExpanded || [];
660
+ if (!shallowEqual(_nextExpanded, expanded)) {
661
+ onExpand(_nextExpanded);
662
+ updateExpanded(_nextExpanded, true);
663
+ }
665
664
  }
666
- }, [context.dataMap, props.data]);
665
+ updateInnerCheckStatus();
666
+ }, [props.data]);
667
667
  useEffect(function () {
668
668
  if (props.datum) return;
669
669
  setValue(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.9.11-beta.10",
3
+ "version": "3.9.11-beta.12",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",