Skip to content

Commit

Permalink
feat(DatePicker): make onChange and value required
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoalvesdulce authored Apr 11, 2022
1 parent 4f6b004 commit a45931f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/components/Datepicker/Datepicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,23 @@ DatePicker.propTypes = {
PropTypes.object,
PropTypes.number,
]),
value: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
value: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired,
isRange: PropTypes.bool,
lang: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
onChange: PropTypes.func,
onChange: function (props, propName) {
var fn = props[propName];
if (
!fn ||
!fn.prototype ||
typeof fn.prototype.constructor !== "function" ||
fn.prototype.constructor.length < 2 ||
fn.prototype.constructor.length > 3
) {
return new Error(
`${propName} must be a function with 2 (if isMonthsMode is on) or 3 args. Args are: year, month and day.`
);
}
},
onYearChange: PropTypes.func,
onShow: PropTypes.func,
onDismiss: PropTypes.func,
Expand All @@ -401,7 +414,6 @@ DatePicker.propTypes = {

DatePicker.defaultProps = {
years: getYearsByNum(5),
onChange(year, month, idx) {},
show: false,
isMonthsMode: false,
isRange: false,
Expand Down

0 comments on commit a45931f

Please sign in to comment.