const [value, setValue] = useState<Node[]>([]);
This should work, I guess (but throws an error). I need to add
const initialValue = [{
children: [{text: ''}]
}];
const [value, setValue] = useState<Node[]>(initialValue);
to show an empty editor. Is that intented?
In my opinion editor should contain at least one block element
Hi @Obiwarn , this gets reported periodically and the fix is to have the editor contain one element. I don't see this behavior changing because otherwise a user can't put focus inside the editor.
Going to close, but feel free to continue a discussion.
@CameronAckermanSEL would it make sense to add a note to the "Installing Slate" document? I assumed each step would work in isolation and was confused why it didn't until I found this issue.
For example
const App = () => {
const editor = useMemo(() => withReact(createEditor()), [])
const [value, setValue] = useState([])
return (
// Add the editable component inside the context.
<Slate editor={editor} value={value} onChange={newValue => setValue(newValue)}>
<Editable />
</Slate>
)
}
Most helpful comment
@CameronAckermanSEL would it make sense to add a note to the "Installing Slate" document? I assumed each step would work in isolation and was confused why it didn't until I found this issue.
For example