Skip to content

Commit

Permalink
fix(easyselect): update auto and fix dataSource is null
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeZhang committed Oct 29, 2020
1 parent e32e489 commit c0ed413
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/easySelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface EasySelectProps {
dataSource?: any[];
clearValueRequest?: boolean;
isLazy?: boolean;
auto?: boolean;
filterLocal?: boolean;
servise?: (str: string) => Promise<any>;
}
Expand All @@ -27,15 +28,15 @@ class EasySelect extends React.Component<EasySelectProps & SelectProps, EasySele
};

static getDerivedStateFromProps({ dataSource }) {
if (dataSource.length !== 0) return { dataSource }
if (dataSource && dataSource.length !== 0) return { dataSource }
return null
}

componentDidMount = () => {
const { autoValue = '', dataSource = [] } = this.props;
const { autoValue = '', dataSource = [], auto = false } = this.props;
if (dataSource.length > 0) {
this.lazyDataSource(dataSource)
} else {
} else if(auto) {
this.getDataSource(autoValue);
}
}
Expand Down

0 comments on commit c0ed413

Please sign in to comment.