{"record":{"id":"8fb241a9270c9e40","repo":"ianstormtaylor/slate","slug":"slate-editor-is-invalid-you-passed-scrubber","errorCode":null,"errorMessage":"[Slate] editor is invalid! You passed: ${Scrubber.stringify(editor)}","messagePattern":"\\[Slate\\] editor is invalid! You passed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/slate-react/src/components/slate.tsx","lineNumber":48,"sourceCode":"    onChange,\n    onSelectionChange,\n    onValueChange,\n    initialValue,\n    ...rest\n  } = props\n\n  // Run once on first mount, but before `useEffect` or render\n  React.useState(() => {\n    if (!Node.isNodeList(initialValue)) {\n      throw new Error(\n        `[Slate] initialValue is invalid! Expected a list of elements but got: ${Scrubber.stringify(\n          initialValue\n        )}`\n      )\n    }\n\n    if (!Editor.isEditor(editor)) {\n      throw new Error(\n        `[Slate] editor is invalid! You passed: ${Scrubber.stringify(editor)}`\n      )\n    }\n\n    editor.children = initialValue\n    Object.assign(editor, rest)\n  })\n\n  const { selectorContext, onChange: handleSelectorChange } =\n    useSelectorContext()\n\n  const onContextChange = useCallback(() => {\n    if (onChange) {\n      onChange(editor.children)\n    }\n    if (\n      onSelectionChange &&\n      editor.operations.find(op => op.type === 'set_selection')","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-react/src/components/slate.tsx#L30-L66","documentation":"The <Slate> component validates that the editor prop is a real Slate Editor instance (Editor.isEditor). Passing a plain object, a factory's un-configured return, or something with a different shape fails this check and throws on mount before any rendering.","triggerScenarios":"<Slate editor={{}} ...>; passing createEditor result from a different slate version/instance; passing a React state value, a ref, or an editor-like object missing required properties (isEditor marker, operations, etc.).","commonSituations":"Multiple copies of the slate package in node_modules (npm/yarn hoisting issues) so instanceof-style checks fail; passing window.editor set incorrectly; HMR or SSR setups replacing modules; upgrading slate/slate-react to mismatched versions.","solutions":["Create the editor with withReact(createEditor()) from the same slate-react/slate versions and pass that instance directly","Deduplicate slate in node_modules (add an npm resolution/yarn nohoist) so only one copy exists","Verify package versions of slate and slate-react match (no cross-major mix)"],"exampleFix":"// before\n<Slate editor={editorFromState} initialValue={value}> // plain object\n\n// after\nconst editor = useMemo(() => withReact(createEditor()), [])\n<Slate editor={editor} initialValue={value}>","handlingStrategy":"type-guard","validationCode":"if (!Editor.isEditor(editor)) {\n  throw new Error('Pass a withReact(createEditor()) instance to <Slate>')\n}","typeGuard":"const isSlateEditor = (e: unknown): e is Editor => Editor.isEditor(e)","tryCatchPattern":null,"preventionTips":["Create the editor once with useMemo(() => withReact(createEditor()), [])","Deduplicate slate copies in node_modules (resolutions/nohoist)","Keep slate and slate-react versions matched"],"tags":["editor-instance","validation","react","version-mismatch","slate"],"backgroundTag":"invalid-editor-instance","analyzedSha":"72a37c701e5da4bb13a305d416d9c070d19d3a45","analyzedAt":"2026-08-27T23:04:51.145Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}