“Proptipe” Kode Jawaban

Proptypes Array of Objects

MyComponent.propTypes = {
  items: PropTypes.arrayOf(
    PropTypes.shape({
      code: PropTypes.string,
      id: PropTypes.number,
    })
  ),
};
Outrageous Opossum

Proptipe

import PropTypes from "prop-types";

MyComponent.propTypes = {
  name: PropTypes.string,
  id: PropTypes.number.isRequired,
  img: PropTypes.string
  grades: PropTypes.arrayOf(PropTypes.number),
  friends: PropTypes.arrayOf(
    PropTypes.shape({
      id: PropTypes.number,
    })
  ),
  list: PropTypes.arrayOf(PropTypes.any),
};

MyComponent.defaultProps = {
  img: "https://picsum.phones/200/300",
}
Inexpensive Impala

Proptipe

import PropTypes from 'prop-types';

class Greeting extends React.Component {
  render() {
    return (
      <h1>Hello, {this.props.name}</h1>
    );
  }
}

Greeting.propTypes = {
  name: PropTypes.string
};
Victorious

bereaksi propthpes atau

size: PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.number
]),
Strange Sandpiper

Jawaban yang mirip dengan “Proptipe”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya