小编new*_*rad的帖子

react/typescript:参数'props'隐含有'any'类型错误

当我从react-bootstrap尝试这个示例代码时,我不断收到错误,例如"参数'上下文'隐含地具有'任意'类型;"类型'Readonly <{}>'上不存在属性'值'."

在form.tsx中:

class FormExample extends React.Component {
  constructor(props, context) {
    super(props, context);

    this.handleChange = this.handleChange.bind(this);

    this.state = {
      value: ''
    };
  }

  getValidationState() {
    const length = this.state.value.length;
    if (length > 10) return 'success';
    else if (length > 5) return 'warning';
    else if (length > 0) return 'error';
    return null;
  }

  handleChange(e) {
    this.setState({ value: e.target.value });
  }

  render() {
    return (
      <form>
        <FormGroup
          controlId="formBasicText"
          validationState={this.getValidationState()}
        >
          <ControlLabel>Working example with validation</ControlLabel>
          <FormControl
            type="text"
            value={this.state.value}
            placeholder="Enter text"
            onChange={this.handleChange}
          />
          <FormControl.Feedback …
Run Code Online (Sandbox Code Playgroud)

twitter-bootstrap typescript reactjs redux

7
推荐指数
3
解决办法
1万
查看次数

标签 统计

reactjs ×1

redux ×1

twitter-bootstrap ×1

typescript ×1