diff --git a/site/source/components/conversation/DateInput.tsx b/site/source/components/conversation/DateInput.tsx index 549747b00..42feb305b 100644 --- a/site/source/components/conversation/DateInput.tsx +++ b/site/source/components/conversation/DateInput.tsx @@ -1,4 +1,4 @@ -import { lazy, Suspense, useCallback } from 'react' +import { lazy, Suspense, useCallback, useMemo } from 'react' import { styled } from 'styled-components' import { InputProps } from '@/components/conversation/RuleInput' @@ -43,7 +43,7 @@ export default function DateInput({ [onChange] ) - const dateValue = convertDate(value) + const dateValue = useMemo(() => new Date(convertDate(value) ?? NaN), [value]) return (
@@ -68,9 +68,9 @@ export default function DateInput({ }> console.log('DateField onChange:', onChange), [onChange]) + useEffect( + () => console.log('DateField defaultSelected:', defaultSelected), + [defaultSelected] + ) + useEffect( + () => console.log('DateField refs.reference:', refs.reference), + [refs.reference] + ) + const oldDefaultSelected = useRef(defaultSelected) useEffect(() => { if ( typeof defaultSelected !== 'undefined' && oldDefaultSelected.current?.getTime() !== defaultSelected.getTime() ) { - console.log('DateField useEffect loop ?') + console.log('DateField useEffect loop ?', defaultSelected) handleDaySelect(defaultSelected) oldDefaultSelected.current = defaultSelected }