fix(ui): filter with source not working
This commit is contained in:
parent
60f82a5157
commit
9316d38b53
1 changed files with 6 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import { FilterType } from 'App/types/filter/filterType';
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import stl from './FilterSource.module.css';
|
||||
import cn from 'classnames';
|
||||
import { debounce } from 'App/utils';
|
||||
|
||||
interface Props {
|
||||
filter: any;
|
||||
|
|
@ -10,12 +11,16 @@ interface Props {
|
|||
function FilterSource(props: Props) {
|
||||
const { filter } = props;
|
||||
const [value, setValue] = useState(filter.source && filter.source[0] ? filter.source[0] : '');
|
||||
const debounceUpdate: any = React.useCallback(debounce(props.onUpdate, 1000), [props.onUpdate]);
|
||||
|
||||
useEffect(() => {
|
||||
setValue(filter.source && filter.source[0] ? filter.source[0] : '');
|
||||
}, [filter]);
|
||||
|
||||
const write = ({ target: { value, name } }: any) => setValue(value);
|
||||
const write = ({ target: { value, name } }: any) => {
|
||||
setValue(value);
|
||||
debounceUpdate({ ...filter, source: [value] });
|
||||
}
|
||||
|
||||
const renderFiled = () => {
|
||||
switch (filter.sourceType) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue