mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-01 03:11:44 +02:00
Remove controlled value state (#3153)
This commit is contained in:
committed by
Ian Storm Taylor
parent
5de91cb4ee
commit
6608a5df39
@@ -250,7 +250,6 @@ Now our commands are clearly defined and you can invoke them from anywhere we ha
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [value, setValue] = useState(initialValue)
|
|
||||||
const editor = useMemo(() => withCustom(withReact(createEditor())), [])
|
const editor = useMemo(() => withCustom(withReact(createEditor())), [])
|
||||||
const renderElement = useCallback(props => {
|
const renderElement = useCallback(props => {
|
||||||
switch (props.element.type) {
|
switch (props.element.type) {
|
||||||
@@ -292,10 +291,8 @@ const App = () => {
|
|||||||
</div>
|
</div>
|
||||||
<Editable
|
<Editable
|
||||||
editor={editor}
|
editor={editor}
|
||||||
value={value}
|
|
||||||
renderElement={renderElement}
|
renderElement={renderElement}
|
||||||
renderMark={renderMark}
|
renderMark={renderMark}
|
||||||
onChange={newValue => setValue(newValue)}
|
|
||||||
onKeyDown={event => {
|
onKeyDown={event => {
|
||||||
if (!event.ctrlKey) {
|
if (!event.ctrlKey) {
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user