Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
81 views
in Technique[技术] by (71.8m points)

javascript - Problem with react-window won't show result

I applied the react-window setting but I don't know why it wont show the result of the cell.

This is how I render the children for react window

This i how I apply the Reactwindow import { VariableSizeList as List } from 'react-window'

 const renderBodyColumn = (cell: any, row: any, renderRowSubComponent: any) => {
  const classTd = classname({
    td: true,
    [cell.column.columnClassName]: cell.column.columnClassName
  })
  const styles = {
    flex: cell.column.width + ' 0 auto',
    width: cell.column.width,
    maxWidth:
      cell.column.maxWidth && cell.column.maxWidth <= 1000
        ? cell.column.maxWidth + 'px'
        : 'auto'
  }

  const RenderRow = ({ index, style }) => {
    return (
      <div style={style} key={index}>
        {cell.render('Cell')}
      </div>
    )
  }
  return (
    <div {...cell.getCellProps()} className={classTd} style={{ ...styles }}>
      <List
        height={50}
        itemCount={row.length}
        itemSize={(index) => (index % 2 ? 100 : 100)}
      >
        {RenderRow(cell)}
      </List>
      {renderRowSubComponent && renderRowSubComponent
        ? renderRowSubComponent({ row })
        : ''}
    </div>
  )
}

this is the applied code for props

<div className='tbody' {...getTableBodyProps()}>
    {page.map((row: any, index: number) => {
        prepareRow(row)
        return (
            <div className='tr' key={index} {...row.getRowProps()} {...getTrProps(row)}>
            {row.cells.map((cell: any, index: number) => {
                return (
                <React.Fragment key={index}>
                    {renderBodyColumn(cell, row, renderRowSubComponent)}
                </React.Fragment>
                )
            })}
            </div>
        )
    }
</div>
question from:https://stackoverflow.com/questions/65651272/problem-with-react-window-wont-show-result

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...