react/typescript: Parameter 'props' implicitly has an 'any' type error

前端 未结 4 761
心在旅途
心在旅途 2020-12-31 00:57

When I try this sample code from react-bootstrap, I keep getting errors such as \" Parameter \'context\' implicitly has an \'any\' type; \"Property \'value\' does not exist

4条回答
  •  情话喂你
    2020-12-31 01:29

    In typeScript you should install @types/react and while extending the React.Component you need to specify the props and state types. Here is the example

    import * as React from 'react'
    
    interface Props {
      ... // your props validation
    }
    
    interface State {
      ... // state types
    }
    
    class FormExample extends React.Component {... }
    

提交回复
热议问题