React-native-swipe-list-view: Undefined is not an object (Version 1.3.0)

Created on 21 May 2018  路  5Comments  路  Source: jemise111/react-native-swipe-list-view

I've got this error while try to trigger closeRow function :

undefined is not an object (evaluating 'rowMap[rowKey].closeRow')

I'm using FlatList option. This is my closeRow function code:

closeRow(rowMap, rowKey) {
  rowMap[rowKey].closeRow();
}

This is my trigger touch code :

<TouchableOpacity onPress={ _ => this.closeRow(rowMap, rowData.item.id) }>

This is SwipeListView (FlatList). When I swipe spesific row, another row I've swiped not closing automatically.

aaaa

Please help.

Most helpful comment

Can you try adding a key to your data, so it looks like

"data": [
        {
            "key": 3,
            "id": 3,
            "name": "Daging Burger",
            "quantity": 80
        },
...

or using a key extractor prop:

<SwipeLisView
   keyExtractor={(item, index) => item.id}
   ...
/>

and seeing if that fixes it?

All 5 comments

Hey @nzrin can I see the structure of your data and how you're using the . I'm curious to know if each object in your data has a key property or if you're passing a keyExtractor prop, thanks!

Yes sure, this is my structure of data :

{
    "data": [
        {
            "id": 3,
            "name": "Daging Burger",
            "quantity": 80
        },
        {
            "id": 5,
            "name": "Sos",
            "quantity": 21
        },
        {
            "id": 6,
            "name": "Lada Hitam",
            "quantity": 14
        },
        {
            "id": 7,
            "name": "Mayonis",
            "quantity": 46
        },
        {
            "id": 27,
            "name": "Cheesy",
            "quantity": 6
        },
        {
            "id": 81,
            "name": "Kokpu",
            "quantity": 10
        }
    ]
}

Can you try adding a key to your data, so it looks like

"data": [
        {
            "key": 3,
            "id": 3,
            "name": "Daging Burger",
            "quantity": 80
        },
...

or using a key extractor prop:

<SwipeLisView
   keyExtractor={(item, index) => item.id}
   ...
/>

and seeing if that fixes it?

Thank you! It works fine when I use keyExtractor.

馃憤 glad to hear it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terencestone picture terencestone  路  5Comments

VitaliiK91 picture VitaliiK91  路  3Comments

2JJ1 picture 2JJ1  路  5Comments

Slapbox picture Slapbox  路  3Comments

lsbiosite picture lsbiosite  路  6Comments