Skip to content
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

Get rid of warning #4503

Closed
wants to merge 1 commit into from
Closed

Get rid of warning #4503

wants to merge 1 commit into from

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
@@ -360,7 +360,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
navigationState,
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