【发布时间】:2019-10-01 01:26:57
【问题描述】:
我正在使用 React-virtualized 将数据显示为列表。
我为列表项添加了选定的样式,它假设一旦被点击就会突出显示该项目。
当前的问题是onClick 被触发,但选择样式仅在向上滚动列表时显示。
List component
<div className={styles.autoSizerContainer}>
<AutoSizer>
{({width, height}) => {
// Selected customer styling only fire after scroll
return (
<List
width={width}
height={height}
rowHeight={50}
rowRenderer={this.renderRow}
rowCount={rowCount}
overscanRowCount={3}
className={styles.list}
/>
)
}}
</AutoSizer>
</div>
List item
private renderRow = ({index, key, style}: ListRowProps) => {
const data = this.props.dataList[index];
return (
<div style={style} key={data.id}>
<div className={styles.listItem}>
<div>data.name</div>
<Item key={data.id}
isDataSelected={this.state.selectedId === data.id}
/> //return true will show selected styling
</div>
</div>
)
};
"react-virtualized": "^9.21.0",
"react": "^16.8.4"
欢迎提出任何想法!
谢谢!!!
【问题讨论】: