-
Notifications
You must be signed in to change notification settings - Fork 70
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
it has performance issue when we drag&drop on a tree with about 500 rows open all #192
Comments
@btnguyen76 I recognize the performance challenges. At the very least, I can improve it by reducing unnecessary rendering during drag operations. |
yes, When dragging all my custom nodes are keeping re-rendered. Do you know when you are able to improve it by reducing unnecessary rendering during drag operations? Thanks @minop1205 |
The problem is caused where the top level component in the library is re-rendered during a drag operation. Therefore, a library modification is required to correct the problem. I am currently working on resolving this issue, but have not yet completed the process. |
@minop1205 Any update about this? |
@minop1205 Any updates? |
@minop1205 Are you continuing to work on this? |
Hey everyone! I've uncovered a way to drastically reduce re-renders for our The key is using Hope this helps you out! type CustomNodeProps = {
node: TreeNode;
depth: number;
isOpen: boolean;
onToggle: () => void;
onClick: () => void;
onCtrlClick: () => void;
};
function useFuncImmutable<T extends (...args: any[]) => any>(fn: T) {
const ref = React.useRef(fn);
ref.current = fn;
return React.useCallback((...args: any[]) => {
return ref.current(...args);
}, []) as T;
}
export const CustomNodeWrapper: React.FC<CustomNodeProps> = (props) => {
const onToggle = useFuncImmutable(props.onToggle);
const onClick = useFuncImmutable(props.onClick);
const onCtrlClick = useFuncImmutable(props.onCtrlClick);
return (
<CustomNodeMemo
{...props}
{...{
onToggle,
onClick,
onCtrlClick,
}}
/>
);
}; |
I'm following the doc, everything is working fine. However if we have a tree with about 500 rows openAll, it's very slow (responsive) when we drag&drop
Do you have any suggestion on how to improve performance?
Thank you!
The text was updated successfully, but these errors were encountered: