【问题标题】:I need react multi-select with virtualized list options我需要对虚拟化列表选项进行多选反应
【发布时间】:2022-12-12 16:17:45
【问题描述】:
标签:
react-select
react-virtualized
【解决方案1】:
检查下面的stackblitz 应用程序。对我的要求很有帮助。
https://stackblitz.com/edit/react-select-v2-virtualized
在这个应用程序中,他们用react-virtualized创建了一个react-select组件。
示例代码:
const MenuList = props => {
const rows = props.children;
const rowRenderer = ({ key, index, isScrolling, isVisible, style }) => (
<div key={key} style={style}>{rows[index]}</div>
);
return (
<List
style={{ width: '100%' }}
width={300}
height={300}
rowHeight={30}
rowCount={rows.length}
rowRenderer={rowRenderer}
/>
)
}
内部渲染函数
<Select
components={{ MenuList }}
defaultValue={this.state.options[10]}
options={this.state.options}
/>