20CAKE20.JS
06-components

Components

23

06-components/09-component-ref.tsx

Component Ref

Example

Official Cake20 View example for component ref.

type Editor = {
  focus: () => void;
};

export const refs = {
  editor: component<Editor>(),
};

export default () => (
  <main class="space-y-3">
    <TextEditor ref={refs.editor} />
    <Button onClick={() => refs.editor.focus()}>Focus the editor</Button>
  </main>
);