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

Error thrown in React Native when using Hugeicons components in the Tabs navigation #14

Open
skyapps-co opened this issue Nov 26, 2024 · 1 comment

Comments

@skyapps-co
Copy link

ERROR: A props object containing a "key" prop is being spread into JSX (...)

This error happens when running the React Native apps when using Hugeicons components inside the navigation components, such as the Tabs (the error might happen in other parts of React Native as well). The key prop is special in React and should not be passed via props spreading into JSX elements. If key is included in the props and the component spreads those props into a JSX element, React will issue a warning.

All icon files (ex: AbacusIcon.js) exhibit a "key" property as part of the svg "path" object. That key is not needed and causes problems with some parts of React Native. For instance when using the Hugeicon icon components in the bottoms tab navigation, under the "tabBarIcon:" setting.

VERY SIMPLE SOLUTION: remove or rename that "key" prop inside each (icon).js file containing the SVG paths. There's a few of them in each (icon).js file. I did a batch rename from key: to xKey: and it solves this problem. The key property is a special prop used by React Native and shouldn't be part of the SVG path objects.

Let me know if more information is needed.

@yeana-dev
Copy link

yeana-dev commented Dec 4, 2024

+1

 ERROR  Warning: A props object containing a "key" prop is being spread into JSX:
  let props = {key: someKey, d: ..., fill: ...};
  <Path {...props} />
React keys must be passed directly to JSX without using spread:
  let props = {d: ..., fill: ...};
  <Path key={someKey} {...props} />
    in DashboardSquare01IconIcon (created by TabBarIcon)
    in RCTView (created by View)

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

No branches or pull requests

2 participants