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

refreshCompleterState is needlessly redefined on each render of the settings page #874

Closed
krassowski opened this issue Jul 5, 2024 · 0 comments · Fixed by #875
Closed
Labels
bug Something isn't working

Comments

@krassowski
Copy link
Member

Description

refreshCompleterState is needlessly redefined on each render of the settings page; this also means it is not properly disconnected and may lead to a tiny memory leak

Reproduce

const refreshCompleterState = () => {
setIsCompleterEnabled(
props.completionProvider && props.completionProvider.isEnabled()
);
};
useEffect(() => {
props.completionProvider?.settingsChanged.connect(refreshCompleterState);
return () => {
props.completionProvider?.settingsChanged.disconnect(
refreshCompleterState
);
};
}, [props.completionProvider]);

Expected behavior

It is memoized or moved to within the effect.

Context

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant