babel-plugin-prop-types-schema-generator
Version:
Transfer react prop types to JSON schema
29 lines (26 loc) • 400 B
JavaScript
class Comp extends Component {
static schema = {
type: "object",
required: ["str2", "str4"],
properties: {
str1: {
type: "string"
},
str2: {
type: "string"
},
str3: {
type: "string"
},
str4: {
type: "string"
}
}
};
static propTypes = {
str1: PropTypes.string,
str2: PropTyeps.string.isRequired,
str3: string,
str4: string.isRequired
};
}