Repository navigation
为什么渲染效率会变慢?
#7473
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
import React, { useRef, useEffect, useState } from 'react';
import { Graph } from '@antv/g6';
const G6Graph: React.FC = () => {
const containerRef = useRef(null);
const graphRef = useRef<Graph | null>(null);
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
// 生成节点数据的函数
const generateNodes = (width: number, height: number, nodeCount: number = 3000) => {
// 开始计时
const startTime = performance.now();
};
useEffect(() => {
if (!containerRef.current) return;
}, []);
return (
<div
ref={containerRef}
style={{
width: '1000px',
height: '800px',
border: '1px solid #ccc',
overflow: 'hidden',
}}
/>
);
};
export default G6Graph;
这个是我的react组件,但是似乎渲染5000个节点的时候就变得特别慢,长达10s+,G6最新版本

All reactions