-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
A props object containing a "key" prop is being spread into JSX #11989
Comments
Hey @KrisLau! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro. The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue. You can provide a repro using any of the following:
A snack link is preferred since it's the easiest way to both create and share a repro. If it's not possible to create a repro using a snack, link to a GitHub repo under your username is a good alternative. Don't link to a branch or specific file etc. as it won't be detected. Try to keep the repro as small as possible by narrowing down the minimal amount of code needed to reproduce the issue. Don't link to your entire project or a project containing code unrelated to the issue. See "How to create a Minimal, Reproducible Example" for more information. You can edit your original issue to include a link to the repro, or leave it as a comment. The issue will be closed automatically after a while if you don't provide a repro. |
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
@satya164 Fixed it by moving the key out of the props. My patch file from yarn: diff --git a/src/TabBar.tsx b/src/TabBar.tsx
index e8d0b4c8dcbbe779fcd304f483d2d91c2d5e8dde..203adc927db153df3f8472d4ec67346e1cd7405b 100644
--- a/src/TabBar.tsx
+++ b/src/TabBar.tsx
@@ -364,8 +364,7 @@ export function TabBar<T extends Route>({
const renderItem = React.useCallback(
({ item: route, index }: ListRenderItemInfo<T>) => {
- const props: TabBarItemProps<T> & { key: string } = {
- key: route.key,
+ const props: TabBarItemProps<T> = {
position: position,
route: route,
navigationState: navigationState,
@@ -446,9 +445,9 @@ export function TabBar<T extends Route>({
<>
{gap > 0 && index > 0 ? <Separator width={gap} /> : null}
{renderTabBarItem ? (
- renderTabBarItem(props)
+ renderTabBarItem({key: route.key, ...props})
) : (
- <TabBarItem {...props} />
+ <TabBarItem key={route.key} {...props} />
)}
</>
); |
Hi @KrisLau, which version of react are you using? In my case for
This version should have a peerDependency |
Yes, the warning appears with React 18.3.x. There is no crash for me and the React crew is promising that there is no changes apart of new deprecation warnings |
@antoniogoulao I'm using v18.3.1. My Android builds are running fine on it but I'll make sure to keep an eye out for issues with it! My upgraded version is still sitting on a separate branch because I'm testing all the packages I upgraded haha. |
@linusrush you can use patch-package or yarn's built in patching to patch it in your project if you need it urgently |
+1 and thanks for the patch @KrisLau |
Current behavior
Every time I load my app, after updating a bunch of my packages (of note: react-native, expo), I get this error:
Code:
When i add
renderTabBarItem={() => {}}
, the error disappears so I tried to change the<TabBarItem {...props} />
to<TabBarItem key={props.key} {...props} />
innode_modules/react-native-tab-view/src/TabBar.tsx
but the error did not disappear.Expected behavior
No error
Reproduction
Doesn't show up on snack but I modified this snack to match my code: https://snack.expo.dev/UtHfj87TmrjuCkct-fB9z
Platform
Packages
Environment
The text was updated successfully, but these errors were encountered: