Skip to content

Commit 2e763f6

Browse files
authored
chore: rm option len match (#986)
* chore: rm option len match * chore: clean up
1 parent 83d5af3 commit 2e763f6

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

docs/demo/scroll-loading.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## scroll loading
2+
<code src="../examples/scroll-loading.tsx">

docs/examples/scroll-loading.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Select from 'rc-select';
2+
import React from 'react';
3+
import '../../assets/index.less';
4+
5+
function genData(len: number) {
6+
return new Array(len).fill(0).map((_, index) => ({
7+
label: `label ${index}`,
8+
value: index,
9+
}));
10+
}
11+
12+
const Loading = ({ onLoad }) => {
13+
React.useEffect(() => {
14+
setTimeout(onLoad, 1000);
15+
}, []);
16+
17+
return <div>Loading...</div>;
18+
};
19+
20+
export default () => {
21+
const [options, setOptions] = React.useState(() => genData(10));
22+
23+
return (
24+
<Select
25+
defaultValue={0}
26+
options={[
27+
...options,
28+
{
29+
label: (
30+
<Loading
31+
onLoad={() => {
32+
setOptions(genData(options.length + 5));
33+
}}
34+
/>
35+
),
36+
value: 'loading',
37+
},
38+
]}
39+
/>
40+
);
41+
};

src/OptionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
146146
}
147147

148148
return () => clearTimeout(timeoutId);
149-
}, [open, searchValue, flattenOptions.length]);
149+
}, [open, searchValue]);
150150

151151
// ========================== Values ==========================
152152
const onSelectValue = (value: RawValueType) => {

0 commit comments

Comments
 (0)