# Jalankan perintah dan hubungkan kontrol {#commands-and-state}

Source: [Jalankan perintah dan hubungkan kontrol | Referensi API editor Yurich untuk React · Yurich](https://leeyujoo.com/yurich/id/api/commands-and-state/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

```ts
interface EditorInstance {
  execute(command: string, value?: unknown): void;
  isActive(commandOrName: string, value?: unknown): boolean;
}

const bold = useIsActive(editor, 'toggleBold');
const heading = useIsActive(editor, 'setHeading', 2);
const undoAvailable = useCanUndo(editor);
const redoAvailable = useCanRedo(editor);
const isEmpty = useEditorState(editor, e => (e.el?.textContent ?? '') === '');
```

`execute` menjalankan perintah berdasarkan nama. `isActive` memeriksa format pada pilihan. Instans editor tetap sama, gunakan hook untuk mengikuti status toolbar. Kembalikan nilai primitif dari `useEditorState` jika memungkinkan.

[Hubungkan status React](https://leeyujoo.com/yurich/id/features/react-state/)
