1
- import { createRef , useCallback , useEffect , useMemo , useRef , useState } from "react" ;
1
+ import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
2
2
3
3
import Calendar from "../components/Calendar" ;
4
4
import Footer from "../components/Footer" ;
@@ -93,10 +93,10 @@ const Datepicker = (props: DatepickerType) => {
93
93
} ) ;
94
94
const [ dayHover , setDayHover ] = useState < DateType > ( null ) ;
95
95
const [ inputText , setInputText ] = useState < string > ( "" ) ;
96
- const [ inputRef , setInputRef ] = useState ( createRef < HTMLInputElement > ( ) ) ;
96
+ const [ input , setInput ] = useState < HTMLInputElement | null > ( null ) ;
97
97
98
98
// Custom Hooks use
99
- useOnClickOutside ( containerRef , ( ) => {
99
+ useOnClickOutside ( containerRef . current , ( ) => {
100
100
const container = containerRef . current ;
101
101
if ( container ) {
102
102
hideDatepicker ( ) ;
@@ -313,7 +313,8 @@ const Datepicker = (props: DatepickerType) => {
313
313
displayFormat,
314
314
hideDatepicker,
315
315
i18n : i18n && i18n . length > 0 ? i18n : LANGUAGE ,
316
- input : inputRef ,
316
+ input,
317
+ setInput : ( value : HTMLInputElement | null ) => setInput ( value ) ,
317
318
inputClassName,
318
319
inputId,
319
320
inputName,
@@ -336,37 +337,37 @@ const Datepicker = (props: DatepickerType) => {
336
337
value
337
338
} ;
338
339
} , [
340
+ minDate ,
341
+ maxDate ,
342
+ i18n ,
339
343
asSingle ,
340
- safePrimaryColor ,
341
- configs ,
342
- hideDatepicker ,
343
- period ,
344
- dayHover ,
345
- inputText ,
346
344
onChange ,
347
- showFooter ,
348
- placeholder ,
349
- separator ,
350
- i18n ,
351
- value ,
352
- disabled ,
353
- inputClassName ,
345
+ classNames ,
346
+ configs ,
354
347
containerClassName ,
355
- toggleClassName ,
356
- toggleIcon ,
357
- readOnly ,
358
- displayFormat ,
359
- minDate ,
360
- maxDate ,
361
348
dateLooking ,
349
+ dayHover ,
350
+ disabled ,
362
351
disabledDates ,
352
+ displayFormat ,
353
+ hideDatepicker ,
354
+ input ,
355
+ inputClassName ,
363
356
inputId ,
364
357
inputName ,
365
- startWeekOn ,
366
- classNames ,
367
- inputRef ,
358
+ inputText ,
359
+ period ,
360
+ placeholder ,
368
361
popoverDirection ,
362
+ safePrimaryColor ,
363
+ readOnly ,
369
364
required ,
365
+ separator ,
366
+ showFooter ,
367
+ startWeekOn ,
368
+ toggleClassName ,
369
+ toggleIcon ,
370
+ value ,
370
371
firstGotoDate
371
372
] ) ;
372
373
@@ -392,7 +393,7 @@ const Datepicker = (props: DatepickerType) => {
392
393
return (
393
394
< DatepickerContext . Provider value = { contextValues } >
394
395
< div className = { containerClassNameOverload } ref = { containerRef } >
395
- < Input setContextRef = { setInputRef } />
396
+ < Input />
396
397
397
398
< div className = { popupClassNameOverload } ref = { calendarContainerRef } >
398
399
< Arrow ref = { arrowRef } />
0 commit comments