关于原型的eslint错误“缺少属性验证”

时间:2019-01-16 04:04:50

标签: eslint

我的陪同人员显示道具验证中缺少“已禁用”,但我在第13行中包含了它。

enter image description here

和我的eslint配置

 "eslintConfig": {
    "env": {
      "browser": true,
      "node": true
    },
    "parser": "babel-eslint",
    "extends": "airbnb",
    "plugins": [
      "react",
      "jsx-a11y",
      "import",
      "graphql",
      "prettier"
    ],
    "rules": {
      "react/jsx-filename-extension": 0,
      "linebreak-style": 0,
      "no-console": "off"
    }
  },

抱歉,这是我的第一个问题-代码日志 我无法使我的代码充满色彩

import React, { Component } from 'react';
import './CheckBox.scss';
import PropTypes from 'prop-types';

class Checkbox extends Component {
  static propTypes: {
    disabled: PropTypes.ballon.isRequired,
  };

  constructor(props) {
    super(props);
    console.log(props);
    this.disabled = props.disabled;
  }

  state = { checked: false, disabled: this.disabled };

  handleCheckboxChange = (checkedFlag) => {
    const checkFlag = !checkedFlag;
    this.setState({ checked: checkFlag });
  };

  render() {
    const { checked, disabled } = this.state;
    return (
      <span
        tabIndex={0}
        role="button"
        onKeyPress={() => this.handleCheckboxChange(checked)}
        onClick={() => this.handleCheckboxChange(checked)}
      >
        <input
          onChange={() => {}}
          disabled={disabled}
          checked={checked}
          className="JDcheck_box"
          type="checkbox"
        />
        <span className="JDcheck_box_label">Red</span>
      </span>
    );
  }
}

Checkbox.defaultProps = {
  disabled: false,
};

export default Checkbox;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.1.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.1.1/umd/react-dom.production.min.js"></script>

0 个答案:

没有答案