Skip to content

onMount()

Register a callback that runs after the component is inserted into the DOM.

function onMount(fn: () => void | (() => void)): void
ParamTypeDescription
fn() => void | (() => void)Mount callback. Can return a cleanup function.
import { component, onMount, div } from "@whisq/core";
const App = component(() => {
onMount(() => {
console.log("mounted!");
return () => console.log("cleanup!");
});
return div("Hello");
});