React Native获取平面列表索引

沉默的灵魂

我在flatlist中使用flatlist,我想获取我
在下面的代码中使用的第一个flatlist的索引

<FlatList
  data ={this.state.data}
  renderItem = {(item, index1)=>
    <View>
      <FlatList
        data = {this.state.data2}
        renderItem = {(item, index2) => 
          console.log("parent_index",index1);
          console.log("child_index",index2);
        }
      />
    </View>
  }

我如何获得index1?
我在上面的代码中所做的是未定义的。

RB RB

第一份清单的代码

render() {
    return (
        <View style={{ height: "100%", width: "100%", backgroundColor: 'red' }}>
          <FlatList
            data={this.state.data}
            renderItem={({ item, index }) => {
              return (
                this.renderSecondFlatlist(index)
              );

            }
            }
          />
        </View>
    )
  }

第二个flatList的代码,您将在其中传递第一个FlatList的“索引”

 renderSecondFlatlist(index1) {
        return (
          <View style={{ flex: 1, backgroundColor: 'pink' }}>

            <FlatList
              data={this.state.data2}
              renderItem={(item, index2) => {
                /*return (
                  <Text>{index1}</Text>
                );*/
                console.log("index:-",index1);
              }
              }
            />
          </View>
        );
      }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在 React Native 中,如何从 json 数组动态获取平面列表中的键

如何解决“试图获取超出范围索引 NaN 的框架”-React 本机平面列表?

React Native:平面列表未呈现

React Native:在平面列表中使用挂钩

React Native中的函数内部的平面列表

React Native 中的反向平面列表

React Native for循环获取索引

从表获取平面链接列表

获取 WiFi 列表 React Native

React Native useState 防止重新渲染平面列表

React Native 中的可点击平面列表项

在React Native中组件未在平面列表中返回

React Native:使用useCallback优化平面列表渲染项目

React Native 中的自定义平面列表项

想在React Native中自动滚动平面列表

在平面列表中使用本地img(React-Native)

React Native:uri在平面列表中多次呈现

在 React Native 中更新平面列表中的参数

React Native Firestore 集合不呈现平面列表

未定义的平面列表不是对象React-native

如何立即更新渲染的平面/截面列表项 React Native

基于类别的 React Native 更新平面列表

从QTreeView中的QModelIndex获取平面行索引

在Java 8中限制并获取平面列表

获取平面列表中单个项目的位置

获取对象 React Native 的列表属性

如何使用正则表达式获取字符串的特定部分并将其放入平面列表(react-native)

带有100多个列表项的React-Native平面列表的性能问题

在React Native中单击项目时,如何关闭模式列表并从平面列表返回值?