Reputation: 472
Trying to get a clear answer on how to assign propTypes for React Components passed as a prop.
Is it even necessary that I check this prop type, and if so, how would I go about using proptypes for the following exapmle:
import React from "react";
import PropTypes from "prop-types";
import styles from "./NavIcons.module.css";
function NavIcons(props) {
return (
<div className={styles.navIcons}>{props.children}</div>
);
}
NavIcons.propTypes = {
children: // WHAT GOES HERE?
};
export default NavIcons;
Upvotes: 0
Views: 911
Reputation: 5766
It's going to be one or more nodes
-
NavIcons.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
]),
};
Upvotes: 1