'ValueChanging' does not exist on type 'Readonly<{}>'

后端 未结 2 1962
执笔经年
执笔经年 2021-02-19 09:54

I\'m trying to implement a handler, in React, for a survey implemented in SurveyJS. This is for multiple-choice questions that may have answers like \"None of the Above\" or \"P

2条回答
  •  迷失自我
    2021-02-19 10:19

    The most likely cause for this is that you don't specify the type for your component's state in its class definition, so it defaults to {}. You can fix it by declaring interfaces for the types of props and state and providing these as type arguments to React.Component:

    interface MyComponentProps { /* declare your component's props here */ }
    interface MyComponentState { ValueChanging :  boolean }
    
    class MyComponent extends React.Component {
      constructor(props) {
      ...
    

    You could provide the types directly between the < and >, but using interfaces usually leads to more readable code and promotes reuse. To prevent confusion with components it's also a good idea to use lower-case identifiers for the properties on props and state.

提交回复
热议问题