AK0021
onUnmount() called outside of component setup
What happened
You called onUnmount() outside of a defineComponent() setup function. AkashJS needs an active component context to register lifecycle hooks.
How to fix
Move the onUnmount() call inside defineComponent()'s setup function.
Example
ts
// Bad
import { onUnmount } from "akashjs";
function setupCleanup() {
onUnmount(() => console.log("cleaned up")); // no component context!
}
// Good
import { defineComponent, onUnmount } from "akashjs";
const Subscription = defineComponent(() => {
const ws = new WebSocket("/events");
onUnmount(() => {
ws.close();
});
return () => h("div", {}, "Connected");
});