Skip to content

AK0040

Component setup must return a render function

What happened

The setup function you passed to defineComponent() returned something other than a function. AkashJS expects setup to return a render function () => AkashNode that describes the component's UI.

How to fix

Make sure your setup function returns a function (the render function), not a raw value, object, or undefined.

Example

ts
// Bad — returning a node directly
const MyComponent = defineComponent(() => {
  return h("div", {}, "Hello"); // returns a node, not a function
});

// Bad — returning nothing
const MyComponent = defineComponent(() => {
  const name = signal("world");
  // forgot to return!
});

// Good — return a render function
const MyComponent = defineComponent(() => {
  const name = signal("world");

  return () => h("div", {}, `Hello, ${name()}`);
});

Released under the MIT License.