Add empty dependency array to useEffect hook

This limits the file watch listener to only attach once and not on every
render which is unnecessary.
This commit is contained in:
Subho 2024-07-12 18:37:10 +05:30 committed by Martin Pitt
parent b37df688b2
commit ddcf092678

View file

@ -32,7 +32,7 @@ export const Application = () => {
const hostname = cockpit.file('/etc/hostname');
hostname.watch(content => setHostname(content?.trim() ?? ""));
return hostname.close;
});
}, []);
return (
<Card>