小编Spe*_*pec的帖子

从 flatlist 获取索引 react native

所以我基本上是在寻找错误和我做错了什么,我得到了每个键不同的数据,我试图获取activeRow的数据,由于某种原因我没有定义,这是怎么回事在?谢谢!尝试记录“this.props.index”后我变得未定义我已经调用了构造函数(道具)和超级(道具),所以我不知道为什么我要记录我的道具它说未定义而不是给我索引或项目...

有我的渲染!

render() {
  const swipeSettings = {
    autoClose: true,
    buttonWidth: 130,
    onClose: (secId, rowId, direction) => {
      if (this.state.activeRowKey != null) {
        this.setState({ activeRowKey: null })
      }
    },
    onOpen: (secId, rowId, direction) => {
      this.setState({ activeRowKey: this.props.index })
      console.log(this.state.activeRowKey)
    },
    right: [
      {
        onPress: () => {

        },
        text: 'Verify', type: 'default', backgroundColor: 'lime', color: 'black', component: (
          <View
            style={{
              flex: 1,
              alignItems: 'center',
              justifyContent: 'center',
              flexDirection: 'column',
            }}
          >
            <Ionicons name="md-checkmark" size={40} />
          </View>
        )
      }
    ],
    left: …
Run Code Online (Sandbox Code Playgroud)

native reactjs react-native react-native-flatlist

0
推荐指数
1
解决办法
4832
查看次数