From 9e7275b201c26a85704af33fa90493ca8b6672fa Mon Sep 17 00:00:00 2001 From: Alexey Andriyanenko Date: Fri, 10 Apr 2020 16:55:25 +0300 Subject: [PATCH] [Rating] Warn if precision prop is less than 0.1 --- packages/material-ui-lab/src/Rating/Rating.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/material-ui-lab/src/Rating/Rating.js b/packages/material-ui-lab/src/Rating/Rating.js index 3f47cd06d33ef4..1ff17f2d7ab71d 100644 --- a/packages/material-ui-lab/src/Rating/Rating.js +++ b/packages/material-ui-lab/src/Rating/Rating.js @@ -567,7 +567,17 @@ Rating.propTypes = { /** * The minimum increment value change allowed. */ - precision: PropTypes.number, + precision: chainPropTypes(PropTypes.number, (props) => { + if (props.precision < 0.1) { + return new Error( + [ + 'Material-UI: the prop `precision` should be above 0.1.', + 'A value below this limit has an imperceptible impact.', + ].join('\n'), + ); + } + return null; + }), /** * Removes all hover effects and pointer events. */