-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If items don't have the key attribute, rowMap is useless #360
Comments
+1 |
Hey @michaelkowalski @elioncho I'm trying to repro this but I'm just not seeing the same issues. I'm going to lay out everything I'm looking at and you tell me what I'm missing. Here is my example code. I do not have Note that the log in Also note when I invoke
|
I don't see anything wrong. This is what I'm personally doing. I am trying to display an array of basic array of objects:
If I remove the keyExtractor prop and add the key property to every element of the array it works. I'm not sure what I'm doing wrong then. |
Hey @elioncho I'm not seeing any |
I copied the whole component and the closeRow and deleteRow functions in the following example. The only thing I'm not copying are the styles.
If I remove the line that sets the key attribute on the result array (see the useEffect method), I will get a:
on the console.log in the closeRow function. |
Hey @elioncho thanks for the detailed example and sorry for the delay in responding. So in your example if you don't have a
to this:
And all should work as intended :) let me know if that's not the case, thanks! |
Works perfectly, thanks! |
Going to close this, please reopen if anyone else has issues, thanks |
Jessie @jemise111 I'm wondering, why does the My keys are all integers, everywhere. Coming at this straight and clean, no legacy to worry about, this machination is a source of cognitive loading, and code complexity. So I'm fascinated, why a string, strictly?
|
Hey @StevenBlack in this case above I was simply using the key provided by the OP's
You could, in theory, use integers for your keys. This component will function properly. However you will get a warning from react-native. See this discussion for more: |
ah! So ignore the warning. Cool! That's valuable input. Thank you, Jessie @jemise111. |
Hello, if the items in the list don't have the
key
attrubute,rowMap
becomes one big merged row. I tried to use keyExtractor, but SwipeList seems to ignore it and still needs the key attr in the data prop.The problem in my case is that I had to explicitly add the
key
attribute to the data prop to use.closeRow()
.Is this a bug or am I doing something wrong? For me the expected behavior would be to use any data shape, a proper keyExtractor and still have the
rowMap
working correctly. Please correct me if I'm wrong.The text was updated successfully, but these errors were encountered: