我在这段代码中使用了一个linter。
import React, { Component } from 'react';
import { Modal, ModalHeader, ModalBody, ModalFooter } from
'reactstrap';
import PropTypes from 'prop-types';
export default class Sumo extends Component {
render() {
return(
<Modal isOpen={this.props.modal} toggle={this.props.toggle}
className={this.props.className}>
<form action="/demo" method="post">
<ModalHeader toggle={this.props.toggle}>Schedule a One-on-one
Online Demo Now!</ModalHeader>
<ModalBody>
<div className="form-group">
<input className="form-control" type="text"
placeholder="name" required/>
</div>
<div className="form-group">
<input className="form-control" type="email"
placeholder="email" required/>
</div>
<div className="form-group">
<input className="form-control" type="tel"
placeholder="phone number" required/>
</div>
<div className="form-group">
<textarea className="form-control" rows="4"
placeholder="How can we help you?"/>
</div>
</ModalBody>
<ModalFooter>
<button className="btn btn-success">Submit</button>
</ModalFooter>
</form>
</Modal>
);
}
}
Sumo.PropTypes = {
modal: PropTypes.string,
toggle: PropTypes.string,
className: PropTypes.string
};
我得到的错误消息是: &#39;模态&#39;道具验证中缺少。 &#39;肘节&#39;道具验证中缺少。 &#39;的className&#39;道具验证中缺少。
答案 0 :(得分:0)
正确的语法如下。尝试一下小改动。
Sumo.propTypes = {
modal: PropTypes.string,
toggle: PropTypes.string,
className: PropTypes.string
};