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

fix: BottomNavigation warn when shifting with the wrong number of tabs #3408

Merged
merged 1 commit into from
Oct 18, 2022

Conversation

brunohkbx
Copy link
Collaborator

Summary

Recently when working on a new feature I realized that the component BottomNavigation crashes when the prop shifting is true but the number of tabs is < 2 as in the following screenshot

Error message

Test plan

  1. Open the example APP
  2. Go to the example/src/Examples/BottomNavigationExample.tsx
  3. Pass the prop shifting to the BottomNavigation component
  4. Modify the routes to have a single one instead
  5. See the warning popping up

Warning message

@brunohkbx
Copy link
Collaborator Author

Hey @lukewalczak is been a while since my last contribution 😄. I wasn't sure if I should point this PR to the branch main or 4.0

@@ -352,6 +352,14 @@ const BottomNavigation = ({
}: Props) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm wondering if we can change shifting = navigationState.routes.length > 3 to shifting = navigationState.routes.length >= 2
Would that be considered a breaking change?

Copy link
Member

Choose a reason for hiding this comment

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

Would that be considered a breaking change?

Partially it's because it affects users with two tabs, who didn't want shiftingstyle to be applied. Why would you like to change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just thought it would make more sense since the interpolation animation expects at least 2 items. So having 2 tabs would be perfectly fine to enable the animation.
I'm totally ok keeping it as it is 😃

@brunohkbx brunohkbx force-pushed the fix/throw-warning-in-bottom-navigation branch from 300d110 to 4d28ea4 Compare October 11, 2022 17:44
@github-actions
Copy link

The mobile version of example app from this branch is ready! You can see it here

.

1 similar comment
@github-actions
Copy link

The mobile version of example app from this branch is ready! You can see it here

.

@lukewalczak
Copy link
Member

Hey @brunohkbx, thanks for your contribution!

I wasn't sure if I should point this PR to the branch main or 4.0

Generally, please target the main branch. I will then port that commit to the next 4.x release, once gather more bug fixes applied to both versions.

@brunohkbx brunohkbx changed the base branch from 4.0 to main October 17, 2022 16:00
@lukewalczak
Copy link
Member

Hey @brunohkbx, you have a lot of conflicts after changing the target branch. I think the easiest way will be to push your changes again on that branch however having main as a base branch.

Please let me know if you need some assist on that ✌🏽

@brunohkbx brunohkbx force-pushed the fix/throw-warning-in-bottom-navigation branch from 4d28ea4 to b4eca7b Compare October 18, 2022 04:41
@callstack-bot
Copy link

callstack-bot commented Oct 18, 2022

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

@github-actions
Copy link

The mobile version of example app from this branch is ready! You can see it here

.

@brunohkbx
Copy link
Collaborator Author

brunohkbx commented Oct 18, 2022

@lukewalczak Fixed it, sorry I couldn't get back to it earlier. While rebasing this PR I found another issue and opened #3415 to address it.

@lukewalczak
Copy link
Member

@brunohkbx no problem, I will check another PR as well. Please correct the tests since CI is failing on that check.

@brunohkbx brunohkbx force-pushed the fix/throw-warning-in-bottom-navigation branch from b4eca7b to 09a597a Compare October 18, 2022 19:32
@github-actions
Copy link

The mobile version of example app from this branch is ready! You can see it here

.

@lukewalczak lukewalczak merged commit ef448b1 into main Oct 18, 2022
@lukewalczak lukewalczak deleted the fix/throw-warning-in-bottom-navigation branch October 18, 2022 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants