-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Future chore - BottomNavigation: React 18.3 to warn about spreading key props in JSX #4401
Comments
Include the actual error as text so it's easier to find when searching 🙄
|
Same issue. Waiting on the resolution. |
Same issue here with React Native v0.74 and React 18.3.1 (which was the version suggested by the official react native upgrade instructions) |
This is my solution (I am applying it as a patch file in my project) diff --git a/src/components/BottomNavigation/BottomNavigationBar.tsx b/src/components/BottomNavigation/BottomNavigationBar.tsx
index 0bfe303bfb443396ede776726faa0f8ba32752cd..a59ae061dcaa51f026e78de0ccfd536318dd0aee 100644
--- a/src/components/BottomNavigation/BottomNavigationBar.tsx
+++ b/src/components/BottomNavigation/BottomNavigationBar.tsx
@@ -360,7 +360,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
navigationState,
renderIcon,
renderLabel,
- renderTouchable = (props: TouchableProps<Route>) => <Touchable {...props} />,
+ renderTouchable = ({ key, ...props }: TouchableProps<Route>) => <Touchable key={key} {...props} />,
getLabelText = ({ route }: { route: Route }) => route.title,
getBadge = ({ route }: { route: Route }) => route.badge,
getColor = ({ route }: { route: Route }) => route.color, |
Any update on this? |
I made a modification to the "renderTouchable" function in the file and it solved the problem. To find the file in the project, navigate to: Look for this:
and replace it with:
|
There's a related issue for react-native-tab-view.. here's a patch: |
Thanks @therbta it 's work |
Hey, I've encountered the issue too, but it seems the patch doesn't working Here what I've found in my BottomNavigationBar.tsx : When I apply the patch I got this :
Does someone know how to fix that? |
Hi all! I have the same issue. Thanks |
The answer of @therbta or @CommanderRedYT both work. Note that there are two places of renderTouchable inside BottomNavigation.tsx file :
You should only make change in this:
After that reload app, I no longer see red warning about spreading key props in JSX. Note that this change must be made manually in node_module. It still haven't updated in react-native-paper package. |
hey i have same error when migrated to Expo SDK 52. please fix it |
I am not able to find this renderTouchable = ({ key, ...props }: TouchableProps) => <Touchable key={key} {...props} />, |
i've added a post-install script in my project to temporarily fix the warning package.json
/scripts/postinstall.js
|
@kvbalib You might rather want to use this: https://www.npmjs.com/package/patch-package |
@CommanderRedYT thanks not really - patch-package is an overkill for me in this case, hopefully someone will fix it soon - then it's just one line of code to delete :) |
it depend on version. As I check on https://github.com/callstack/react-native-paper/blob/main/src/components/BottomNavigation/BottomNavigationBar.tsx it still exists at line 363. @DKS0751081 |
Guys this error is also resulting in the first tab not being shown by
default in a tab navigator. It somehow goes to the last tab.
…On Thu, 21 Nov 2024, 21:52 satosoft.com, ***@***.***> wrote:
I am not able to find this renderTouchable = ({ key, ...props }:
TouchableProps) => <Touchable key={key} {...props} />, I can only see
renderTouchable?: (props: TouchableProps) => React.ReactNode; @satosoft
<https://github.com/satosoft>
it depend on version. As I check on
https://github.com/callstack/react-native-paper/blob/main/src/components/BottomNavigation/BottomNavigationBar.tsx
it still exists at line 363.
—
Reply to this email directly, view it on GitHub
<#4401 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPW73DXW4UPO6OEHJE4VED2BYCDZAVCNFSM6AAAAABHOXC6WKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJRGY4TCOBSG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi all! I have the same issue. Thanks |
Line 451: <TabBarItem {...props} key={props.key} /> FYI: This is fixed in 4.X.X |
thanks! |
This issue has been reported since May, yet still no official fix for it. Paper is really great UI library but our team is now considering going away from it unfortunately |
I decided not to patch but simply provide the BottomNavigation with the renderTouchable instead, e.g., import { BottomNavigation, TouchableRipple } from 'react-native-paper'; <BottomNavigation |
I'm not using BottomNavigation directly. I use |
Current behaviour
React 18.3 adds a warning about spreading props containing a "key" prop (facebook/react#25697). Current version of React Native uses 18.2, but I think we'd expect it to be migrated in the next version.
When testing with React 18.3, we get this warning on a Touchable inside BottomNavigation.Bar.
Expected behaviour
Expected not to receive warnings.
How to reproduce?
Fresh React Native project, but change React version to 18.3.1.
Reproduction example: https://github.com/nick42d/KeySpreadReproduction
Preview
What have you tried so far?
This is my mistake for upgrading React too early, but since I spent a few hours debugging this figure my pain can be your gain.
Your Environment
The text was updated successfully, but these errors were encountered: