我正在尝试创建一个8列的表,每列包含一个元素。由于某些原因,我在文本输入的on change事件中遇到了延迟。将列数减少到4以下可改善体验。这可能是有道理的,但是我也尝试增加列的数量,结果发现对于10个或更多的列,体验还是很棒的。您可以检查我的超级简单React应用程序,在其中可以动态更改列数-http://com.react.table-with-inputs.s3-website.eu-central-1.amazonaws.com/。
这是我的代码:
import React from 'react'; import { AutoSizer, Table, Column } from 'react-virtualized'; class App extends React.Component { constructor(props) { super(props); this.state = { numOfCols: '8', }; } rowGetter = ({ index }) => { return { index }; }; renderHeaderCell = ({ label }) => { return ( {label} ); }; renderCell = ({ rowIndex, columnIndex }) => { return ( ); }; render() { return (NUMBER OF COLUMNS this.setState({ numOfCols: e.target.value })} />); } } export default App;
{({ height, width }) => ( { (() => { const cols = []; for (let i = 0; i
)}) } return cols; })() }
编辑1:这仅在Chrome(Mac和Windows,台式机和移动设备)上发生。它不会在Safari或Firefox(非桌面版和移动版)上复制。
编辑2:我试图删除AutoSizer
但没有任何更改。上载了可以渲染或不显示Table
with AutoSizer
容器的更新版本(http://com.react.table-with-inputs.s3-website.eu-central-1.amazonaws.com/)。