From a36cda89049c3fa240ce41be293c08143ccfb292 Mon Sep 17 00:00:00 2001 From: Christian Paul Date: Wed, 11 Apr 2018 20:26:45 -0700 Subject: [PATCH] Move explanation of `isRequired` and show it in `PropTypes.shape` --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 869ba2e..89b1091 100644 --- a/README.md +++ b/README.md @@ -102,10 +102,13 @@ MyComponent.propTypes = { // An object with property values of a certain type optionalObjectOf: PropTypes.objectOf(PropTypes.number), + // You can chain any of the above with `isRequired` to make sure a warning + // is shown if the prop isn't provided. + // An object taking on a particular shape optionalObjectWithShape: PropTypes.shape({ - color: PropTypes.string, - fontSize: PropTypes.number + optionalProperty: PropTypes.string, + requiredProperty: PropTypes.number.isRequired }), // An object with warnings on extra properties @@ -114,8 +117,6 @@ MyComponent.propTypes = { requiredProperty: PropTypes.number.isRequired }), - // You can chain any of the above with `isRequired` to make sure a warning - // is shown if the prop isn't provided. requiredFunc: PropTypes.func.isRequired, // A value of any data type