add debug log for DateField

pull/2819/head
Jérémy Rialland 2023-09-25 20:02:37 +02:00 committed by Jérémy Rialland
parent 2e18a46550
commit 7ccb1716c5
1 changed files with 13 additions and 0 deletions

View File

@ -86,6 +86,8 @@ export default function DateField(props: DateFieldProps) {
}, [refs.reference])
const handleInputChange = (value: string) => {
console.log('DateField handleInputChange', value)
setIsOpen(false)
setIsChangeOnce(true)
setInputValue(value)
@ -109,6 +111,8 @@ export default function DateField(props: DateFieldProps) {
const handleDaySelect = useCallback(
(date?: Date) => {
console.log('DateField handleDaySelect', date)
setSelected(date)
if (date) {
const value = formatDate(date, format)
@ -123,12 +127,21 @@ export default function DateField(props: DateFieldProps) {
[close, onChange]
)
useEffect(() => {
console.log('DateField mounted')
return () => {
console.log('DateField unmounted')
}
}, [])
const oldDefaultSelected = useRef<Date | undefined>(defaultSelected)
useEffect(() => {
if (
typeof defaultSelected !== 'undefined' &&
oldDefaultSelected.current?.getTime() !== defaultSelected.getTime()
) {
console.log('DateField useEffect loop ?')
handleDaySelect(defaultSelected)
oldDefaultSelected.current = defaultSelected
}