NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Key/List issue - Check the render method of `ForwardRef(Container)`.

Open veho-paul opened this issue 2 years ago • 2 comments

Description

Rendering children in a container is throwing a "key" error

CodeSandbox/Snack link

See below

Steps to reproduce

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See error

NativeBase Version

^3.4.0

Platform

  • [x] Android
  • [ ] CRA
  • [ ] Expo
  • [X] iOS
  • [ ] Next

Other Platform

No response

Additional Information

<Container>
  <Heading size="md" color={colors.brand.blue} mb={5}>
    {clientName}
  </Heading>
</Container>

doesn't throw the error, but as soon as I add another child

<Container>
  <Heading size="md" color={colors.brand.blue} mb={5}>
    {clientName}
  </Heading>
  <Text>Hey</Text>
</Container>

I get this error:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `ForwardRef(Container)`.

Specifically this is happening in a ListHeaderComponent of a FlatList

veho-paul avatar Jul 14 '22 21:07 veho-paul

Thank you @veho-paul for reporting this issue. We will look into it.

Krithikj20 avatar Jul 15 '22 04:07 Krithikj20

Hey, Can you share reproducible snack link for the issue ? I wasn't able to reproduce the issue.

ankit-tailor avatar Jul 15 '22 07:07 ankit-tailor

Updated @ 3.4.17 but the issue still exists. Switching to react-native's flat-list or removing the ListHeaderComponent "hide" the warning.

v-x2 avatar Sep 26 '22 18:09 v-x2

I have this problem when I have a native-base Pressable in the ListHeaderComponent and the Pressable have more than one child.

Wrap their children in one component work fine for me. The alert is no longer displayed.

I was able to test and the alert is displayed if for a component (it doesn't matter which one, View, Pressable...) it has multiple children.

HyperNovax avatar Jan 25 '23 14:01 HyperNovax