You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi again
I want to use async and I just copy your example code, and I get my data from parent and passing to child with props , but i have memory exceed error , what should i do ?
I'm beginner in react :)
my error :
`
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
`
and my code : componentDidMount() { var treeData = this.props.treeData if(treeData !== ''){ if(treeData !== []){ var treeDataArray = [] console.log(treeData, 'treeData') treeData.forEach(element => { let newTreeObj = { id: element.pid, name: ${element.title} - ${element.entityTypeName}`
}
treeDataArray.push(newTreeObj)
})
this.setState({
data: treeDataArray
})
}
}
}
render() {
return (
<SuperTreeview
data={this.state.data}
onUpdateCb={(updatedData) => {
this.setState({ data: updatedData });
}}
isCheckable={() => (false)}
isDeletable={() => (false)}
isExpandable={(node, depth) => (true)}
onExpandToggleCb={(node, depth) => {
const asyncNodeId = 3;
if (node.id === asyncNodeId && node.isExpanded === true) {
// This will show the loading sign
node.isChildrenLoading = true;
setTimeout(() => {
const updatedData = cloneDeep(this.state.data);
// Remove loading sign
updatedData[asyncNodeId - 1].isChildrenLoading = false;
// Make sure node is expanded
updatedData[asyncNodeId - 1].isExpanded = true;
// Set Children data that you potentially
// got from an API response
updatedData[asyncNodeId - 1].children = [
{
id: 22,
name: 'Child 1'
},
{
id: 23,
name: 'Child 2'
}
];
// Update state
this.setState({ data: updatedData })
}, 1700);
}
}}
onCheckToggleCb={(nodes) => {
const checkedNode = nodes[0];
if (checkedNode.id === 5) {
const checkState = nodes[0].isChecked;
applyCheckStateTo(nodes);
function applyCheckStateTo(nodes) {
nodes.forEach((node) => {
node.isChecked = checkState
if (node.children) {
applyCheckStateTo(node.children);
}
})
}
}
}}
/>
);
}
`
The text was updated successfully, but these errors were encountered:
hi again
I want to use async and I just copy your example code, and I get my data from parent and passing to child with props , but i have memory exceed error , what should i do ?
I'm beginner in react :)
my error :
`
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
`
and my code :
componentDidMount() { var treeData = this.props.treeData if(treeData !== ''){ if(treeData !== []){ var treeDataArray = [] console.log(treeData, 'treeData') treeData.forEach(element => { let newTreeObj = { id: element.pid, name:
${element.title} - ${element.entityTypeName}`}
treeDataArray.push(newTreeObj)
})
}
render() {
return (
`
The text was updated successfully, but these errors were encountered: