Skip to content

Commit c0ed413

Browse files
author
jeromeZhang
committed
fix(easyselect): update auto and fix dataSource is null
1 parent e32e489 commit c0ed413

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/easySelect/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface EasySelectProps {
99
dataSource?: any[];
1010
clearValueRequest?: boolean;
1111
isLazy?: boolean;
12+
auto?: boolean;
1213
filterLocal?: boolean;
1314
servise?: (str: string) => Promise<any>;
1415
}
@@ -27,15 +28,15 @@ class EasySelect extends React.Component<EasySelectProps & SelectProps, EasySele
2728
};
2829

2930
static getDerivedStateFromProps({ dataSource }) {
30-
if (dataSource.length !== 0) return { dataSource }
31+
if (dataSource && dataSource.length !== 0) return { dataSource }
3132
return null
3233
}
3334

3435
componentDidMount = () => {
35-
const { autoValue = '', dataSource = [] } = this.props;
36+
const { autoValue = '', dataSource = [], auto = false } = this.props;
3637
if (dataSource.length > 0) {
3738
this.lazyDataSource(dataSource)
38-
} else {
39+
} else if(auto) {
3940
this.getDataSource(autoValue);
4041
}
4142
}

0 commit comments

Comments
 (0)