我想在我正在呈现的Grid
之一上访问公开方法recomputeGridSize。我创建了ref
但是当我尝试调用该方法时,似乎该方法不可用。
请参阅下文,在最终Grid
:
render() {
const { structure, columnHeaderIndex, variables } = this.props;
const {
sidebarWidth,
headerHeight,
headerRowCount,
height,
gridHeight,
gridWidth
} = variables;
const rowCount = structure.length;
const columnCount = columnHeaderIndex.length;
if (structure.length === 0 || columnCount.length === 0) return null;
console.log(this.bodyGrid);
return (
<div>
<ScrollSync>
{({
clientHeight,
clientWidth,
onScroll,
scrollHeight,
scrollLeft,
scrollTop,
scrollWidth
}) => {
return (
<div>
<div
className="LeftSideGridContainer"
style={{
position: 'absolute',
top: 0,
left: 0,
backgroundColor: 'black',
borderBottom: '1px solid black',
color: 'white'
}}
>
<Grid
cellRenderer={this.renderLeftHeaderCell}
className="header-grid"
width={sidebarWidth + 1}
columnWidth={sidebarWidth + 1}
height={headerHeight}
rowHeight={headerHeight}
rowCount={1}
columnCount={1}
/>
</div>
<div
className="LeftSideGridContainer"
style={{
position: 'absolute',
top: headerHeight,
left: 0,
borderTop: '1px solid black',
backgroundColor: 'white',
color: 'black'
}}
>
<Grid
cellRenderer={this.renderLeftSideCell}
columnWidth={sidebarWidth + 1}
columnCount={1}
className="left-side-grid"
height={height}
rowHeight={gridHeight}
rowCount={rowCount}
scrollTop={scrollTop}
width={sidebarWidth + 1}
/>
</div>
<div className="grid-column">
<AutoSizer disableHeight>
{({ width }) =>
<div>
<div
style={{
height: headerHeight,
width: width - scrollbarsize(),
overflow: 'hidden'
}}
>
<Grid
className="header-grid"
cellRenderer={this.cellRenderer}
cellRangeRenderer={this.renderHeaderCells}
columnWidth={gridWidth}
columnCount={columnCount}
height={headerHeight}
rowHeight={headerHeight / headerRowCount}
rowCount={headerRowCount}
scrollLeft={scrollLeft}
width={width - scrollbarsize()}
/>
</div>
<div
style={{
height: height,
width: width,
borderLeft: '1px solid black',
borderTop: '1px solid black'
}}
>
<Grid
className="calendar-body"
cellRenderer={this.cellRenderer}
cellRangeRenderer={this.cellRangeRenderer}
columnWidth={gridWidth}
columnCount={columnCount}
height={height}
rowHeight={gridHeight}
rowCount={rowCount}
width={width}
onScroll={onScroll}
ref={ref => {
this.bodyGrid = ref;
}}
/>
</div>
</div>}
</AutoSizer>
</div>
</div>
);
}}
</ScrollSync>
</div>
);
}
你可以看到,如果我console.log(this.bodyGrid)
没有文档中定义的公共方法可用:
我在这里做错了吗?