Skip to content
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

开关展开行会重新渲染所有展开行 #1013

Open
pangxiaoli opened this issue Aug 18, 2023 · 0 comments
Open

开关展开行会重新渲染所有展开行 #1013

pangxiaoli opened this issue Aug 18, 2023 · 0 comments

Comments

@pangxiaoli
Copy link

pangxiaoli commented Aug 18, 2023

const [expandRended, setExpandRended] = React.useState(false);
if (process.env.NODE_ENV !== 'production') {
devRenderTimes(props);
}
const expanded = expandedKeys && expandedKeys.has(rowKey);
React.useEffect(() => {
if (expanded) {
setExpandRended(true);
}
}, [expanded]);

目前是用一个set存的所有已展开行的key,然后到这里react就会重新渲染所有已展开的行,造成不必要的开销。是否应该将是否展开作为行数据的一个属性,配合key,react就可以做到精准更新这一行。

目前的方案还存在一个问题,数据源改变后 #mergedExpandedKeys并没有改变,当数据源重新变回来后又以展开状态渲染了表格。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant