Skip to content

useWorkbookEditor

function useWorkbookEditor(options?):
| EditorHandle
| null;

An editor for a React component: made when the component mounts and destroyed, with its worker, when it unmounts. It’s null on the first render, before it’s made, so render <WorkbookEditor> once it isn’t.

  • file is opened when the editor is ready, and again when it changes.

  • Theme, language, user, schemas and custom lists follow options as they change, without closing the workbook. A new array or object with the same entries isn’t a change, so they can be written inline.

  • onSave, onEvent, onError and onLinkClick can be new functions on every render: the editor calls the latest. Whether there’s an onSave at all is read when the editor is made.

  • Every other option is read when the editor is made. To change one, give the component a new key, which makes a new editor.

Parameter Type
options WorkbookEditorHookOptions

| EditorHandle | null