Skip to content

Commit

Permalink
fix: 优化点-2
Browse files Browse the repository at this point in the history
  • Loading branch information
yxh01132861 committed Oct 11, 2023
1 parent 347742b commit eb7afdc
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const FilterDate: React.FC<FilterDateProps> = ({ value: defaultValue, ope
return getOptions(format);
}, [format]);

const onTypeChange = (e: string) => {
const onGranularityChange = (e: string) => {
const _granularity = options.find((item) => item.value === e) as Granularity;
if (_granularity) {
setGranularity(_granularity);
Expand All @@ -53,10 +53,10 @@ export const FilterDate: React.FC<FilterDateProps> = ({ value: defaultValue, ope
};

useEffect(() => {
if (timer) {
if (!isEmpty(defaultValue)) {
onChange(getTimeFormat(defaultValue, granularity.value, operator));
}
}, [defaultValue, granularity]);
}, [defaultValue, granularity, operator]);

useEffect(() => {
if (format && options.length) {
Expand All @@ -71,7 +71,7 @@ export const FilterDate: React.FC<FilterDateProps> = ({ value: defaultValue, ope
placeholder="时间粒度"
value={granularity.value}
style={{ marginRight: 10 }}
onChange={onTypeChange}
onChange={onGranularityChange}
options={options}
/>

Expand Down

0 comments on commit eb7afdc

Please sign in to comment.