Skip to content

Conversation

@bmatasar
Copy link

Motivation

Metro displays a warning:
Warning: A props object containing a "key" prop is being spread into JSX: let props = {key: someKey, route: ..., borderless: ..., centered: ..., rippleColor: ..., onPress: ..., onLongPress: ..., testID: ..., accessibilityLabel: ..., accessibilityRole: ..., accessibilityState: ..., style: ..., children: ...}; <Touchable {...props} /> React keys must be passed directly to JSX without using spread: let props = {route: ..., borderless: ..., centered: ..., rippleColor: ..., onPress: ..., onLongPress: ..., testID: ..., accessibilityLabel: ..., accessibilityRole: ..., accessibilityState: ..., style: ..., children: ...}; <Touchable key={someKey} {...props} /> in BottomNavigation.Bar (created by BottomNavigation)

Related issue

Test plan

Metro displays a warning:

Warning: A props object containing a "key" prop is being spread into JSX:
  let props = {key: someKey, route: ..., borderless: ..., centered: ..., rippleColor: ..., onPress: ..., onLongPress: ..., testID: ..., accessibilityLabel: ..., accessibilityRole: ..., accessibilityState: ..., style: ..., children: ...};
  <Touchable {...props} />
React keys must be passed directly to JSX without using spread:
  let props = {route: ..., borderless: ..., centered: ..., rippleColor: ..., onPress: ..., onLongPress: ..., testID: ..., accessibilityLabel: ..., accessibilityRole: ..., accessibilityState: ..., style: ..., children: ...};
  <Touchable key={someKey} {...props} />
    in BottomNavigation.Bar (created by BottomNavigation)
@callstack-bot
Copy link

Hey @bmatasar, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@nick42d
Copy link

nick42d commented Sep 21, 2024

This is a duplicate of #4494

@bmatasar bmatasar closed this Sep 21, 2024
@bmatasar bmatasar deleted the patch-1 branch September 21, 2024 13:44
renderIcon,
renderLabel,
renderTouchable = (props: TouchableProps<Route>) => <Touchable {...props} />,
renderTouchable = (props: TouchableProps<Route>) => <Touchable {...props} key={props.key} />,
Copy link

@ChromeQ ChromeQ Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually remove the "key" from the props, so it will still be included and spread further down inside the Touchable component.
It should be:

renderTouchable = ({ key, ...props }: TouchableProps<Route>) => <Touchable {...props} key={key} />,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants