* Вывод в консоль скрыт в TimezoneSelect

* Добавлена обработка falsy значений в DatePickerWrapper
This commit is contained in:
goodmice 2022-04-18 10:51:50 +05:00
parent 905036cc71
commit 6d833c75c5
2 changed files with 6 additions and 9 deletions

View File

@ -37,14 +37,11 @@ export const TimezoneSelect = memo<TimezoneSelectProps>(({ onChange, value, defa
useEffect(() => setDefaultTimezone(defaultValue ? findTimezoneId(defaultValue) : null), [defaultValue]) useEffect(() => setDefaultTimezone(defaultValue ? findTimezoneId(defaultValue) : null), [defaultValue])
useEffect(() => setId(value ? findTimezoneId(value) : null), [value]) useEffect(() => setId(value ? findTimezoneId(value) : null), [value])
const onValueChanged = useCallback((id: TimezoneId | null) => { const onValueChanged = useCallback((id: TimezoneId | null) => onChange?.({
console.log(id) timezoneId: id,
onChange?.({ hours: id ? rawTimezones[id] : 0,
timezoneId: id, isOverride: false,
hours: id ? rawTimezones[id] : 0, }), [onChange])
isOverride: false,
})
}, [onChange])
return (<Select {...other} onChange={onValueChanged} value={id} defaultValue={defaultTimezone} />) return (<Select {...other} onChange={onValueChanged} value={id} defaultValue={defaultTimezone} />)
}) })

View File

@ -18,7 +18,7 @@ export const DatePickerWrapper = memo<DatePickerWrapperProps>(({ value, onChange
format={defaultFormat} format={defaultFormat}
defaultValue={moment()} defaultValue={moment()}
onChange={(date) => onChange?.(date)} onChange={(date) => onChange?.(date)}
value={isUTC ? moment.utc(value).local() : moment(value)} value={value && (isUTC ? moment.utc(value).local() : moment(value))}
{...other} {...other}
/> />
)) ))