Skip to content

Commit

Permalink
Add empty dependency array to useEffect hook
Browse files Browse the repository at this point in the history
This limits the file watch listener to only attach once and not on every
render which is unnecessary.
  • Loading branch information
subhoghoshX authored and martinpitt committed Jul 12, 2024
1 parent b37df68 commit ddcf092
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Application = () => {
const hostname = cockpit.file('/etc/hostname');
hostname.watch(content => setHostname(content?.trim() ?? ""));
return hostname.close;
});
}, []);

return (
<Card>
Expand Down

0 comments on commit ddcf092

Please sign in to comment.