# कमांड चलाएँ और स्थिति पढ़ें {#commands-and-state}

Source: [कमांड चलाएँ और स्थिति पढ़ें | Yurich React एडिटर का API रेफ़रेंस · Yurich](https://leeyujoo.com/yurich/hi/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` नाम से कमांड चलाता है। `isActive` चयन का फ़ॉर्मैट जाँचता है। स्थिति को React हुक से पढ़ें। `useEditorState` से प्रिमिटिव लौटाने पर हर बार नया ऑब्जेक्ट बनाने की ज़रूरत नहीं पड़ती।

[React स्थिति जोड़ें](https://leeyujoo.com/yurich/hi/features/react-state/)
