1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Add PropType validation for next/head children (#5504)

Give `Head` a more detailed error messages in dev mode by validating the children prop's PropTypes.
This commit is contained in:
Patrick Smith 2018-10-28 18:04:35 -04:00 committed by Tim Neutkens
parent 2c343baeba
commit 98568046a3

View file

@ -100,4 +100,12 @@ function unique () {
}
}
if (process.env.NODE_ENV === 'development') {
const exact = require('prop-types-exact')
Head.propTypes = exact({
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired
})
}
export default sideEffect(reduceComponents, onStateChange, mapOnServer)(Head)