Comparing version 5.2.0 to 5.2.1
@@ -178,2 +178,3 @@ import * as React from 'react'; | ||
delayedDragEnterLogic: Record<Key, number>; | ||
loadingRetryTimes: Record<Key, number>; | ||
state: TreeState; | ||
@@ -180,0 +181,0 @@ dragStartMousePosition: any; |
@@ -24,2 +24,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import DropIndicator from './DropIndicator'; | ||
var MAX_RETRY_TIMES = 10; | ||
@@ -43,2 +44,3 @@ var Tree = /*#__PURE__*/function (_React$Component) { | ||
_this.delayedDragEnterLogic = void 0; | ||
_this.loadingRetryTimes = {}; | ||
_this.state = { | ||
@@ -563,3 +565,4 @@ keyEntities: {}, | ||
_this.onNodeLoad = function (treeNode) { | ||
return new Promise(function (resolve, reject) { | ||
var key = treeNode.key; | ||
var loadPromise = new Promise(function (resolve, reject) { | ||
// We need to get the latest state of loading/loaded keys | ||
@@ -574,3 +577,2 @@ _this.setState(function (_ref) { | ||
onLoad = _this$props5.onLoad; | ||
var key = treeNode.key; | ||
@@ -611,4 +613,18 @@ if (!loadData || loadedKeys.indexOf(key) !== -1 || loadingKeys.indexOf(key) !== -1) { | ||
}; | ||
}); | ||
}); // If exceed max retry times, we give up retry | ||
_this.loadingRetryTimes[key] = (_this.loadingRetryTimes[key] || 0) + 1; | ||
if (_this.loadingRetryTimes[key] >= MAX_RETRY_TIMES) { | ||
var currentLoadedKeys = _this.state.loadedKeys; | ||
warning(false, 'Retry for `loadData` many times but still failed. No more retry.'); | ||
_this.setUncontrolledState({ | ||
loadedKeys: arrAdd(currentLoadedKeys, key) | ||
}); | ||
resolve(); | ||
} | ||
reject(e); | ||
@@ -620,3 +636,6 @@ }); | ||
}); | ||
}); | ||
}); // Not care warning if we ignore this | ||
loadPromise.catch(function () {}); | ||
return loadPromise; | ||
}; | ||
@@ -623,0 +642,0 @@ |
@@ -178,2 +178,3 @@ import * as React from 'react'; | ||
delayedDragEnterLogic: Record<Key, number>; | ||
loadingRetryTimes: Record<Key, number>; | ||
state: TreeState; | ||
@@ -180,0 +181,0 @@ dragStartMousePosition: any; |
@@ -56,2 +56,4 @@ "use strict"; | ||
// Fully accessibility support | ||
var MAX_RETRY_TIMES = 10; | ||
var Tree = /*#__PURE__*/function (_React$Component) { | ||
@@ -74,2 +76,3 @@ (0, _inherits2.default)(Tree, _React$Component); | ||
_this.delayedDragEnterLogic = void 0; | ||
_this.loadingRetryTimes = {}; | ||
_this.state = { | ||
@@ -590,3 +593,4 @@ keyEntities: {}, | ||
_this.onNodeLoad = function (treeNode) { | ||
return new Promise(function (resolve, reject) { | ||
var key = treeNode.key; | ||
var loadPromise = new Promise(function (resolve, reject) { | ||
// We need to get the latest state of loading/loaded keys | ||
@@ -601,3 +605,2 @@ _this.setState(function (_ref) { | ||
onLoad = _this$props5.onLoad; | ||
var key = treeNode.key; | ||
@@ -638,4 +641,18 @@ if (!loadData || loadedKeys.indexOf(key) !== -1 || loadingKeys.indexOf(key) !== -1) { | ||
}; | ||
}); | ||
}); // If exceed max retry times, we give up retry | ||
_this.loadingRetryTimes[key] = (_this.loadingRetryTimes[key] || 0) + 1; | ||
if (_this.loadingRetryTimes[key] >= MAX_RETRY_TIMES) { | ||
var currentLoadedKeys = _this.state.loadedKeys; | ||
(0, _warning.default)(false, 'Retry for `loadData` many times but still failed. No more retry.'); | ||
_this.setUncontrolledState({ | ||
loadedKeys: (0, _util.arrAdd)(currentLoadedKeys, key) | ||
}); | ||
resolve(); | ||
} | ||
reject(e); | ||
@@ -647,3 +664,6 @@ }); | ||
}); | ||
}); | ||
}); // Not care warning if we ignore this | ||
loadPromise.catch(function () {}); | ||
return loadPromise; | ||
}; | ||
@@ -650,0 +670,0 @@ |
{ | ||
"name": "rc-tree", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"description": "tree ui component for react", | ||
@@ -5,0 +5,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
339319
7271