bug
App crashes when using with react-slate.
TypeError: Cannot read property 'length' of undefined
at Editable (.../node_modules/slate-react/dist/index.js:1807:38)
Which is this line
if (placeholder && editor.children.length === 1 && Array.from(slate.Node.texts(editor)).length === 1 && slate.Node.string(editor) === '') {
Children is undefined at this point.
When I remove the placeholder as a prop (to bypass this line) the app crashes differently
Error: Unable to find the path for Slate node: {"operations":[],"selection":null,"marks":null,"defaultValue":[{"children":[{"text":"This is editable plain text!","marks":[]}]}]}
at Object.findPath (.../node_modules/slate-react/dist/index.js:291:11)```
Sandbox: https://codesandbox.io/s/slate-reproductions-n58jf?file=/index.js
Image: https://i.imgur.com/D1GqTvZ.png
Slate: 0.58.0
Browser: Chrome
OS: Windows
@TedChenNZ where did you find the example? If you change defaultValue to value the example renders
https://codesandbox.io/s/slate-reproductions-qslr2?file=/index.js
If you refer to https://github.com/ianstormtaylor/slate/blob/master/Changelog.md#0510--december-5-2019 you must now manage the state yourself
@TedChenNZ , Slate does not at this version support usage in an uncontrolled way, and does not support the defaultValue prop. You need to pass a value to the value prop, and then pass an onChange handler in order to receive new value states from the editor.
I'm going to close this issue as this is not defective behavior. If you have any questions or comments, please feel free to post in this issue.
@CameronAckermanSEL that makes sense! I thought it did because the codepen in the issue template wasn't controlled.
I've updated the codepen here with the latest version and with value/onChange used instead of defaultValue if you wanted to use it: https://codesandbox.io/s/slate-reproductions-c7gyg
Created a PR here https://github.com/ianstormtaylor/slate/pull/3659
Most helpful comment
@TedChenNZ where did you find the example? If you change
defaultValuetovaluethe example rendershttps://codesandbox.io/s/slate-reproductions-qslr2?file=/index.js
If you refer to https://github.com/ianstormtaylor/slate/blob/master/Changelog.md#0510--december-5-2019 you must now manage the state yourself