@@ -19,12 +19,48 @@ class Calendar extends Component {
19
19
startWith : "Wed" ,
20
20
activeView : "default" ,
21
21
fixRange : [ ] ,
22
- activeMouseEnter : false
22
+ activeMouseEnter : false ,
23
+ invalid : true
23
24
} ;
24
25
}
25
26
26
27
componentDidMount ( ) {
27
- const { date, step, startWith, startWithDates, only, type } = this . props ;
28
+ const {
29
+ date,
30
+ step,
31
+ startWith,
32
+ startWithDates,
33
+ only,
34
+ type,
35
+ visible,
36
+ onDayClick
37
+ } = this . props ;
38
+ let invalid = false ;
39
+ if ( ! startWithDates ) {
40
+ console . error ( `Prop "startWithDates" is Required` ) ;
41
+ invalid = true ;
42
+ }
43
+ if ( visible === undefined ) {
44
+ console . error ( `Prop "visible" is Required` ) ;
45
+ invalid = true ;
46
+ }
47
+ if ( type === "range" && step === undefined ) {
48
+ console . error ( `Prop "step" is Required` ) ;
49
+ invalid = true ;
50
+ }
51
+ if ( type === "range" && startWith === undefined ) {
52
+ console . error ( `Prop "startWith" is Required` ) ;
53
+ invalid = true ;
54
+ }
55
+ if ( ! onDayClick ) {
56
+ console . error ( `Prop "onDayClick" is Required` ) ;
57
+ invalid = true ;
58
+ }
59
+ console . log ( "TCL: componentDidMount -> invalid" , invalid ) ;
60
+ this . setState ( { invalid : invalid } ) ;
61
+ if ( invalid ) {
62
+ return false ;
63
+ }
28
64
const dateInMoment = moment ( date ) ;
29
65
const month = dateInMoment . format ( "YYYY-MMM" ) ,
30
66
year = dateInMoment . format ( "YYYY" ) ,
@@ -53,7 +89,14 @@ class Calendar extends Component {
53
89
54
90
componentDidUpdate ( prevProps , prevState ) {
55
91
if ( prevProps !== this . props ) {
56
- const { date, step, startWith, startWithDates, type } = this . props ;
92
+ const {
93
+ visible,
94
+ date,
95
+ step,
96
+ startWith,
97
+ startWithDates,
98
+ type
99
+ } = this . props ;
57
100
const dateInMoment = moment ( startWithDates [ 0 ] ) ;
58
101
const month = dateInMoment . format ( "YYYY-MMM" ) ,
59
102
year = dateInMoment . format ( "YYYY" ) ,
@@ -269,8 +312,11 @@ class Calendar extends Component {
269
312
}
270
313
} ;
271
314
render ( ) {
272
- const { visible, only, type } = this . props ;
273
- if ( ! visible ) return false ;
315
+ const { visible, only, type, startWithDates } = this . props ;
316
+ console . log ( "TCL: render -> this.state.invalid" , this . state . invalid ) ;
317
+ if ( this . state . invalid ) {
318
+ return false ;
319
+ }
274
320
const {
275
321
activeDateIndex : activeDateArray ,
276
322
month : monthObj ,
0 commit comments