jemise111 / react-native-swipe-list-view

A React Native ListView component with rows that swipe open and closed
https://www.npmjs.com/package/react-native-swipe-list-view
MIT License
2.78k stars 528 forks source link

rowMap returns me all the props instead of the actual rowMap. React Native 0.69.3 #607

Open developerElmo opened 2 years ago

developerElmo commented 2 years ago

Describe the bug Hi! So our app recently changed version to 0.69.3 and maintained the react-native-swipe-list-view to 3.2.9. After upgrading our app crashes whenever it involves closing any row item.

Upon further checking it seems that the reason behind it rowMap returns me the props instead of the actual rowMap object.

To Reproduce To reproduce the scenario here is the code of my test screen:

` import { View, Text, TouchableOpacity, StyleSheet } from 'react-native' import React from 'react' import { SwipeListView } from 'react-native-swipe-list-view' import { faker } from '@faker-js/faker'

const SwipeListViewTest = () => { const dataTest = Array(5) .fill("") .map((_, i) => ({ key: ${i}, text: item #${i}, data: [ { productName: faker.commerce.productName(), } ] }))

const keyExtractor = (item: any, index: number) => { return item.productName + index }

const renderItem = (data: any, rowMap: any) => { return ( <TouchableOpacity onPress={() => console.log('on press', rowMap)} style={styles.mainView}>

Test {data.item.productName}
  </TouchableOpacity>
)

}

return ( <SwipeListView useSectionList sections={dataTest} keyExtractor={keyExtractor} renderItem={renderItem} leftOpenValue={70} disableLeftSwipe disableRightSwipe /> ) }

const styles = StyleSheet.create({ mainView: { height: 50, width: 200, alignItems: 'center', justifyContent: 'center', backgroundColor: 'yellow', alignSelf: 'center' } })

export default SwipeListViewTest `

Screenshots screen: image

log: image

Environment (please complete the following information):

I've read other similar issues like: https://github.com/jemise111/react-native-swipe-list-view/issues/360 https://github.com/jemise111/react-native-swipe-list-view/issues/547

But it seems that it involves a keyExtractor problem but I think my keyExtractor works fine.

If you need additional info please let me know. I am not really sure what other packages are needed that could be affecting my app. Thanks!

lorenz199x commented 2 years ago

I think that error is related on how you handle the data in state. Thanks 👍