Skip to content

AK0010

provide() called outside of component setup

What happened

You called provide() in a plain function or module scope, rather than inside a defineComponent() setup function. AkashJS needs an active component context to register the provided value.

How to fix

Move the provide() call so it runs inside defineComponent()'s setup function.

Example

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

function initTheme() {
  provide("theme", { mode: "dark" }); // not inside defineComponent!
}

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

const ThemeProvider = defineComponent(() => {
  provide("theme", { mode: "dark" });

  return () => slot();
});

Released under the MIT License.