ianstormtaylor/slate · critical · Error
[Slate] editor is invalid! You passed: ${Scrubber.stringify(
Error message
[Slate] editor is invalid! You passed: ${Scrubber.stringify(editor)} What it means
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.
Source
Thrown at packages/slate-react/src/components/slate.tsx:48
onChange,
onSelectionChange,
onValueChange,
initialValue,
...rest
} = props
// Run once on first mount, but before `useEffect` or render
React.useState(() => {
if (!Node.isNodeList(initialValue)) {
throw new Error(
`[Slate] initialValue is invalid! Expected a list of elements but got: ${Scrubber.stringify(
initialValue
)}`
)
}
if (!Editor.isEditor(editor)) {
throw new Error(
`[Slate] editor is invalid! You passed: ${Scrubber.stringify(editor)}`
)
}
editor.children = initialValue
Object.assign(editor, rest)
})
const { selectorContext, onChange: handleSelectorChange } =
useSelectorContext()
const onContextChange = useCallback(() => {
if (onChange) {
onChange(editor.children)
}
if (
onSelectionChange &&
editor.operations.find(op => op.type === 'set_selection')View on GitHub (pinned to 72a37c701e)
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)
Example fix
// before
<Slate editor={editorFromState} initialValue={value}> // plain object
// after
const editor = useMemo(() => withReact(createEditor()), [])
<Slate editor={editor} initialValue={value}> Defensive patterns
Strategy: type-guard
Validate before calling
if (!Editor.isEditor(editor)) {
throw new Error('Pass a withReact(createEditor()) instance to <Slate>')
} Type guard
const isSlateEditor = (e: unknown): e is Editor => Editor.isEditor(e)
Prevention
- Create the editor once with useMemo(() => withReact(createEditor()), [])
- Deduplicate slate copies in node_modules (resolutions/nohoist)
- Keep slate and slate-react versions matched
When it happens
Trigger: <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.).
Common situations: 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.
Related errors
- [Slate] initialValue is invalid! Expected a list of elements
- Got non-numeric path index
- Got non-numeric path index
- Cannot get the relative path of [${path}] inside ancestor [$
- Index must be number
AI-assisted analysis of ianstormtaylor/slate@72a37c701e (2026-08-27).
Data as JSON: /api/errors/8fb241a9270c9e40.
Report an issue: GitHub.