1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-17 21:49:20 +01:00

docs: Added TypeScript info to the Installing Slate walkthrough

This commit is contained in:
Sunny Hirai 2021-03-30 14:58:31 -07:00
parent cd07f2f61b
commit 4b92b752ef

View File

@ -47,6 +47,25 @@ const App = () => {
Of course we haven't rendered anything, so you won't see any changes.
> If you are using TypeScript, you will also need to extend the `Editor` with `ReactEditor` as per the documentation on [TypeScript](/concepts/11-typescript). The example below also includes the custom types required for the rest of this example.
```ts
// TypeScript Users only add this code
import { BaseEditor } from 'slate'
import { ReactEditor } from 'slate-react'
type CustomElement = { type: 'paragraph'; children: CustomText[] }
type CustomText = { text: string }
declare module 'slate' {
interface CustomTypes {
Editor: BaseEditor & ReactEditor & HistoryEditor
Element: CustomElement
Text: CustomText
}
}
```
Next we want to create state for `value`:
```jsx