How can i use Draft with TypeScript?
See original GitHub issueI install the Draft with npm, cmd: npm install --save draft-js, and install the @types command, cmd: npm install @types/draft-js --save, my TypeScript code is :
`class MyEditor extends React.Component<any, any> {
constructor(props) {
super(props);
this.state = { editorState: EditorState.createEmpty() };
}
handleChange(e) {
this.setState({ editorState: e });
}
render() {
return (
<Editor editorState={this.state.editorState} onChange={e => this.handleChange(e)} />
);
}
}
ReactDOM.render(
<MyEditor />,
document.getElementById('editor')
);`
But the IDE tell me: cannot find the name EditorState and Editor. How can i resolve it?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
@types/draft-js - npm
TypeScript definitions for Draft.js. Latest version: 0.11.10 ... Start using @types/draft-js in your project by running `npm i @types/draft-js`.
Read more >@types/draft-js examples - CodeSandbox
Learn how to use @types/draft-js by viewing and forking example apps that make use of @types/draft-js on CodeSandbox. ; draft-js-editor ; editor.
Read more >Rich editor for your react typescript project using hooks
Rich editor for your react typescript project using hooks. Add titles, images and links to your draft.js editor.
Read more >Draft Js Mention Typescript (forked) - StackBlitz
React + TypeScript starter project. ... Draft Js Mention Typescript (forked) ... Compiling application & starting dev server…
Read more >@types/draft-js | Yarn - Package Manager
0 vulnerabilities. TypeScript definitions for Draft.js ... Use it. $ yarn add @types/draft-js ... jsDelivr: cdn.jsdelivr.net/npm/@types/draft-js/.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Works for me with
import { Editor, EditorState } from "draft-js"