react-native-draggable-grid icon indicating copy to clipboard operation
react-native-draggable-grid copied to clipboard

property 'x' of undefined

Open kwkeat opened this issue 5 years ago • 8 comments

Screenshot 2020-07-31 at 12 19 20 PM

<DraggableGrid numColumns={4} renderItem={this.renderGridViewItem} data={products} onDragRelease={data => { this.setState({data}); }} />

kwkeat avatar Jul 31 '20 04:07 kwkeat

Each item should have a unique key prop to get rid of that error

stevenasi avatar Aug 02 '20 02:08 stevenasi

this is still relevant and it's always showing - even with a proper unique key, seems like it's not even looking for the key prop in the rendered element...

leonzuendel avatar Feb 02 '21 17:02 leonzuendel

Confirmed, setting the key doesn't affect the error. Couldn't make it work.

mderk avatar Mar 08 '21 17:03 mderk

If you use the index of the array, I don't know why but does't work! You can generate an unique key in your object and use it! For me it's work!

mariosantosdev avatar Jul 23 '21 17:07 mariosantosdev

is the issue resolved?please solve it. seems like a buggy pacckage

shirdisai22 avatar Jan 08 '23 09:01 shirdisai22

the problem is in duplicated items by key. If there are 2 or more items with same key value, it will crash

MikhailVasiliev avatar Feb 09 '23 00:02 MikhailVasiliev

@kwkeat You need to have a key named 'key' inside the object you're passing to data here's cheap fix for that

<DraggableGrid
          numColumns={4}
          renderItem={this.render_item}
          data={this.state.data.map(obj => ({ ...obj, key: uuid.v4() }))}
          onDragRelease={(data) => {
            this.setState({data});// need reset the props data sort after drag release
          }}
        />

I'll raise a pr to fix this issue

ritik619 avatar Dec 06 '23 11:12 ritik619

the problem is in duplicated items by key. If there are 2 or more items with same key value, it will crash

thanks, you save my time

tungnc3142 avatar Dec 26 '23 08:12 tungnc3142