feat: DataTable component optimization
This commit is contained in:
parent
5d868af9e7
commit
553736fb84
1 changed files with 19 additions and 16 deletions
|
|
@ -110,11 +110,12 @@ const DataTable = ({
|
||||||
const classes = useStyles({ width })
|
const classes = useStyles({ width })
|
||||||
|
|
||||||
const expandRow = id => {
|
const expandRow = id => {
|
||||||
|
cache.clear(id)
|
||||||
setExpanded(id === expanded ? null : id)
|
setExpanded(id === expanded ? null : id)
|
||||||
}
|
}
|
||||||
|
|
||||||
const cache = new CellMeasurerCache({
|
const cache = new CellMeasurerCache({
|
||||||
defaultHeight: 62,
|
defaultHeight: 58,
|
||||||
fixedWidth: true
|
fixedWidth: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -126,20 +127,22 @@ const DataTable = ({
|
||||||
key={key}
|
key={key}
|
||||||
parent={parent}
|
parent={parent}
|
||||||
rowIndex={index}>
|
rowIndex={index}>
|
||||||
<div style={style}>
|
{({ registerChild }) => (
|
||||||
<Row
|
<div ref={registerChild} style={style}>
|
||||||
width={width}
|
<Row
|
||||||
id={index}
|
width={width}
|
||||||
expWidth={expWidth}
|
id={index}
|
||||||
elements={elements}
|
expWidth={expWidth}
|
||||||
data={data[index]}
|
elements={elements}
|
||||||
Details={Details}
|
data={data[index]}
|
||||||
expanded={index === expanded}
|
Details={Details}
|
||||||
expandRow={expandRow}
|
expanded={index === expanded}
|
||||||
expandable={expandable}
|
expandRow={expandRow}
|
||||||
onClick={onClick}
|
expandable={expandable}
|
||||||
/>
|
onClick={onClick}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</CellMeasurer>
|
</CellMeasurer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +176,7 @@ const DataTable = ({
|
||||||
rowCount={data.length}
|
rowCount={data.length}
|
||||||
rowHeight={cache.rowHeight}
|
rowHeight={cache.rowHeight}
|
||||||
rowRenderer={rowRenderer}
|
rowRenderer={rowRenderer}
|
||||||
overscanRowCount={50}
|
overscanRowCount={5}
|
||||||
deferredMeasurementCache={cache}
|
deferredMeasurementCache={cache}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue