Convert to TypeScript
This needs the usual "I know the `app` element exists" annotation, plus dealing with a non-existing /etc/hostname (in which case the watch will return `null`, and we shouldn't poke that into a `string` state).
This commit is contained in:
parent
4bbb291281
commit
745b4ab8e8
6 changed files with 43 additions and 5 deletions
|
|
@ -30,7 +30,7 @@ export const Application = () => {
|
|||
|
||||
useEffect(() => {
|
||||
const hostname = cockpit.file('/etc/hostname');
|
||||
hostname.watch(content => setHostname(content.trim()));
|
||||
hostname.watch(content => setHostname(content?.trim() ?? ""));
|
||||
return hostname.close;
|
||||
});
|
||||
|
||||
|
|
@ -28,5 +28,5 @@ import "patternfly/patternfly-5-cockpit.scss";
|
|||
import './app.scss';
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
createRoot(document.getElementById("app")).render(<Application />);
|
||||
createRoot(document.getElementById("app")!).render(<Application />);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue