-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hovering tree node in Tree component causes re-render #7266
Comments
Please add a link to reproduce the issue |
https://codesandbox.io/p/sandbox/mantine-react-template-forked-48thrd |
@matejdostal @xauuu @onkar-deshpande ( @rtivital ) We have confirmed that this also occurs in the Controller Story of the Tree component's Storybook. The onMouseOver and onMouseLeave events of the TreeNode component used in the tree are causing re-rendering due to the internal state of the useTree hooks changing. If you do not need this attribute, you can suppress re-rendering by doing the following export function Controller() {
const tree = useTree({
onNodeCollapse: (value) => console.log('Node collapsed:', value),
onNodeExpand: (value) => console.log('Node expanded:', value),
});
console.log(tree);
return (
<div style={{ padding: 40 }}>
<Tree data={data} tree={{...tree, setHoveredNode:()=>{}}} /> {/** Override setHoveredNode */}
<Button onClick={() => tree.expandAllNodes()}>Expand all</Button>
<Button onClick={() => tree.collapseAllNodes()}>Collapse all</Button>
</div>
);
} |
Dependencies check up
What version of @mantine/* packages do you have in package.json?
7.14.3
What package has an issue?
@mantine/core
What framework do you use?
Vite
In which browsers you can reproduce the issue?
All
Describe the bug
When using Tree component to display tree data, I encounter that each time when I hover mouse over tree node thie whole component is re-rendered.
If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
No response
Self-service
The text was updated successfully, but these errors were encountered: