Skip to content

Commit

Permalink
chore: rm option len match (#986)
Browse files Browse the repository at this point in the history
* chore: rm option len match

* chore: clean up
  • Loading branch information
zombieJ authored Oct 17, 2023
1 parent 83d5af3 commit 2e763f6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/demo/scroll-loading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## scroll loading
<code src="../examples/scroll-loading.tsx">
41 changes: 41 additions & 0 deletions docs/examples/scroll-loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Select from 'rc-select';
import React from 'react';
import '../../assets/index.less';

function genData(len: number) {
return new Array(len).fill(0).map((_, index) => ({
label: `label ${index}`,
value: index,
}));
}

const Loading = ({ onLoad }) => {
React.useEffect(() => {
setTimeout(onLoad, 1000);
}, []);

return <div>Loading...</div>;
};

export default () => {
const [options, setOptions] = React.useState(() => genData(10));

return (
<Select
defaultValue={0}
options={[
...options,
{
label: (
<Loading
onLoad={() => {
setOptions(genData(options.length + 5));
}}
/>
),
value: 'loading',
},
]}
/>
);
};
2 changes: 1 addition & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
}

return () => clearTimeout(timeoutId);
}, [open, searchValue, flattenOptions.length]);
}, [open, searchValue]);

// ========================== Values ==========================
const onSelectValue = (value: RawValueType) => {
Expand Down

0 comments on commit 2e763f6

Please sign in to comment.