0

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; 
1

1 Answer 1

1

It's going to be one or more nodes -

NavIcons.propTypes = { children: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.node), PropTypes.node ]), }; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.