> For the complete documentation index, see [llms.txt](/llms.txt).
> The full corpus is at [llms-full.txt](/llms-full.txt).

# useEditorSelector

> **useEditorSelector**\<`TSelected`\>(`editor`, `selector`, `compare`): `TSelected`

Defined in: packages/editor/src/editor/editor-selector.ts:39

Hook to select a value from the editor state.

## Type Parameters

### TSelected

`TSelected`

## Parameters

### editor

[`Editor`](/api/editor/type-aliases/editor/)

### selector

[`EditorSelector`](/api/editor/type-aliases/editorselector/)\<`TSelected`\>

### compare

(`a`, `b`) => `boolean`

## Returns

`TSelected`

## Examples

Pass a selector as the second argument
```tsx
import { useEditorSelector } from '@portabletext/editor'

function MyComponent(editor) {
 const value = useEditorSelector(editor, selector)
}
```

Pass an inline selector as the second argument.
In this case, use the editor context to obtain the schema.
```tsx
import { useEditorSelector } from '@portabletext/editor'

function MyComponent(editor) {
 const schema = useEditorSelector(editor, (snapshot) => snapshot.context.schema)
}
```