Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[example] Fix fast refresh in with-slate example #36095

Merged
merged 4 commits into from Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/with-slate/package.json
Expand Up @@ -7,10 +7,10 @@
},
"dependencies": {
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"slate": "^0.58.4",
"slate-history": "0.58.4",
"slate-react": "^0.58.4"
"react": "^18.0.0",
"react-dom": "^18.0.0",
"slate": "^0.76.1",
"slate-history": "0.66.0",
"slate-react": "^0.76.1"
}
}
27 changes: 12 additions & 15 deletions examples/with-slate/pages/index.js
@@ -1,24 +1,21 @@
import React, { useState, useMemo } from 'react'
import { useState } from 'react'
import { createEditor } from 'slate'
import { Slate, Editable, withReact } from 'slate-react'
import { withHistory } from 'slate-history'

const IndexPage = () => {
const [value, setValue] = useState(initialValue)
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
export default function IndexPage() {
const [editor] = useState(() => withReact(withHistory(createEditor())), [])
const [value, setValue] = useState([
{
children: [
{ text: 'This is editable plain text, just like a <textarea>!' },
],
},
])

return (
<Slate editor={editor} value={value} onChange={(value) => setValue(value)}>
<Slate editor={editor} value={value} onChange={setValue}>
<Editable placeholder="Enter some plain text..." />
</Slate>
)
}

const initialValue = [
{
children: [
{ text: 'This is editable plain text, just like a <textarea>!' },
],
},
]

export default IndexPage