declaring a property in constructor with typescript react

后端 未结 3 1334
北恋
北恋 2021-02-12 13:22

From the draft-js documention, one can (in vanilla React, with no typescript) setup the Draft-js environment thus, noticing that the onChange property can be declar

3条回答
  •  孤城傲影
    2021-02-12 14:02

    Alternatively, you can try it like this:

    private onChange = (editorState) => this.setState({ editorState } as MainState)

    just in the body of the class, where you define other class properties. I dunno, which version you're running, but this code totally works in ES2015 and TypeScript 2.0.10

提交回复
热议问题