Skip to content

Commit d5f8e0f

Browse files
cottomzombieJ
authored andcommitted
hotfix: avoid endless loop if remote folder has no children (react-component#192)
Fix loop loadData https://codesandbox.io/s/217z041myj
1 parent 5f57134 commit d5f8e0f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/TreeNode.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class TreeNode extends React.Component {
276276

277277
// Load data to avoid default expanded tree without data
278278
syncLoadData = (props) => {
279-
const { expanded, loading } = props;
279+
const { expanded, loading, loaded } = props;
280280
const { rcTree: { onNodeLoad } } = this.context;
281281

282282
if (loading) return;
@@ -286,7 +286,7 @@ class TreeNode extends React.Component {
286286
// We needn't reload data when has children in sync logic
287287
// It's only needed in node expanded
288288
const hasChildren = this.getNodeChildren().length !== 0;
289-
if (!hasChildren) {
289+
if (!hasChildren && !loaded) {
290290
onNodeLoad(this);
291291
}
292292
}

0 commit comments

Comments
 (0)