Maximum call stack size exceeded in react app
See original GitHub issueDescribe the bug
export const Tree: FC<TreeProps> = (props) => {
const keyToNodeMap = useRef<KeyToNodeMap>({})
const [data, setData] = useState<TreeSource>(props.treeData)
const doTranslate = useCallback((children: Array<TreeSource>, parent: TreeSource)=>{
children.forEach((item: TreeSource) => {
item.parent = parent
keyToNodeMap.current[item.key] = item
if(item.children && item.children.length > 0) {
doTranslate(item.children, item)
}
})
}, [])
useEffect(() => {
keyToNodeMap.current[data.key] = data
if(data.children && data.children.length > 0) {
// doTranslate(data.children, data) **open this will report the bug**
}
}, [data, doTranslate])
return (
<div className={sc('tree')}>
<div className={sc('tree-nodes')}>
<TreeNode
data={data}
onCollapse={onCollapse}
onCheck={onCheck}
/>
</div>
</div>
)
}
export default Tree;
When the page is loaded for the first time, it is fine, but when I switch the sidebar, an error will be reported
"@storybook/addon-a11y": "^6.3.2",
"@storybook/addon-actions": "6.3.2",
"@storybook/addon-docs": "^6.3.2",
"@storybook/addon-essentials": "^6.3.2",
To Reproduce
My Project:
System macOS 11.2.3 chrome 91.0.4472.114
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
React, Uncaught RangeError: Maximum call stack size ...
I got 'Maximum call stack size exceeded', and similar errors because of framer-motion API dependency, version bigger than 4.1.17 (today's ...
Read more >Bug: Maximum call stack size exceeded (React Devtools ...
The bottom line is that the profiler becomes unresponsive after any interaction with a heavily loaded react page. React version: React: 17.0.2 ...
Read more >JavaScript RangeError: Maximum Call Stack Size Exceeded
The JavaScript RangeError: Maximum call stack size exceeded is an error that occurs when there are too many function calls, or if a...
Read more >Error RangeError: Maximum call stack size exceeded
Sometimes calling a recursive function over and over again, causes the browser to send you Maximum call stack size exceeded error message as...
Read more >React-native debugging error: Maximum call stack size ...
This error is almost always means you have a problem with recursion in JavaScript code, as there isn't any other way in JavaScript...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This part of the reconstruction has been completed, it is a problem with my code, thank you all
wait a moment, I will refactor the code and then give you a reply