반응 가상화를 기반으로 데이터 그리드 구성 요소를 개발 중입니다. 크기를 조정할 수있는 열이있는 고정 헤더가 있어야합니다. 머리글 셀 내용에 따라 머리글의 높이를 변경하고 싶습니다. 난 CellMeasurer을 사용하여 셀의 높이를 계산하고 헤더의 높이를 업데이트합니다.반응 가상화를 사용하여 동적 높이가있는 표 머리글을 구현하는 방법이 있습니까?
문제는 셀이 렌더링 된 후에 계산되므로 (afaik) 높이가 변경된 경우 forceUpdate
을 헤더의 render
내부로 호출해야합니다. 여기
는 render
같이 (완벽한 예입니다 here) 모습입니다 :
render() {
const height = this._cache.rowHeight({ index: 0 });
console.log('render', height, this.props.sizes);
setTimeout(() => {
if (height !== this._cache.rowHeight({ index: 0 })) {
console.log('forceUpdate', this._cache.rowHeight({ index: 0 }))
this.forceUpdate()
}
}, 0)
return (
<Grid
ref={ref => this._grid = ref}
deferredMeasurementCache={this._cache}
width={1500}
height={height}
columnCount={5}
columnWidth={this.columnWidth}
rowCount={1}
rowHeight={this._cache.rowHeight}
cellRenderer={this.renderCell}
/>
);
}
그래서 forceUpdate
어떻게 피하는가하는 질문? 반응 가상화를 사용하여 동적 높이로 그리드 헤더를 구현하는 더 깨끗한 방법이 있습니까?
브라이언, 협조 해 주셔서 감사합니다. 대답은 많은 도움이되었지만 달성하려는 노력과 조금 다릅니다. –