Skip to content

AK0022

onError() called outside of component setup

What happened

You called onError() outside of a defineComponent() setup function. AkashJS needs an active component context to register lifecycle hooks.

How to fix

Move the onError() call inside defineComponent()'s setup function.

Example

ts
// Bad
import { onError } from "akashjs";

onError((err) => console.error(err)); // no component context!

// Good
import { defineComponent, onError } from "akashjs";

const SafeComponent = defineComponent(() => {
  onError((err) => {
    console.error("Component error:", err);
  });

  return () => h("div", {}, "Safe");
});

Released under the MIT License.