Reactjs 更改ListView大小后获取layout.height

Reactjs 更改ListView大小后获取layout.height,reactjs,react-native,react-native-listview,Reactjs,React Native,React Native Listview,我有一个ListView,它使用onLayout道具来检索初始布局属性。此ListView也将被筛选,其中列表项将在添加时被删除。如何在每次更改ListView的大小时获得新的高度 onLayoutAction = (event) => { var layout = event.nativeEvent.layout const {height} = layout this.setState({ currentListHeight : height -

我有一个ListView,它使用onLayout道具来检索初始布局属性。此ListView也将被筛选,其中列表项将在添加时被删除。如何在每次更改ListView的大小时获得新的高度

onLayoutAction = (event) => {
    var layout = event.nativeEvent.layout
    const {height} = layout
    this.setState({
        currentListHeight : height - 61
    })
}

  renderListView = () => {
    if (this.noRowData()) {
      return (
          <AlertMessage title='No Offerings Available' show={this.noRowData()} />
      )
    } else {
      // TODO: fix refreash control below
      return (
          <ListView
            ref='listView'
            onLayout={this.onLayoutAction}
            scrollEventThrottle={16}
            onScroll={this.onScrollAction}
            contentContainerStyle={styles.listContent}
            dataSource={this.state.dataSource}
            renderRow={this.renderRow}
            renderHeader={this.renderHeader}
            renderFooter={this.renderFooter}
            enableEmptySections
            pageSize={15}
            refreshControl={
              <RefreshControl
                refreshing={this.props.isLoading}
                onRefresh={this.handleOnRefresh}
                tintColor='#000000'
                title='Loading...'
                titleColor='#000000'
                colors={['#000000', '#000000', '#000000']}
                progressBackgroundColor='#ffffff' />
              }
            />
      )
    }
  }
挂载和每次布局更改时,应根据文档调用onLayout功能:

我做了一个快速测试,并在我的应用程序的列表视图中添加了一个onLayout函数。每次我在列表中添加项目时,都会调用它。我没有测试删除项目,但我会假设它是相同的

您也可以查看onContentSizeChange。每次ListView使用的ScrollView中的内容更改时,它都会激发