React-native-paper: BottomNavigation with shifting and single route crashes app

Created on 22 Aug 2019  路  4Comments  路  Source: callstack/react-native-paper

Environment

n/a, see Snack below

Description

Configuring a BottomNavigation with a single route and shifting enabled causes the app to crash with Invariant Violation: Bad output range. The crash can be avoided by having at least two routes or disabling shifting.

This is perhaps an obscure edge case, but I ran into it while establishing react-navigation-material-bottom-tabs in a new project, adding one route at a time. I thought I would report it on that repo, but then I tested and found it's a problem with this underlying code. I doubt this is impacting many people in practice, but it could cause difficulties for new people just starting to test the features.

Reproducible Demo

Here's a Snack demonstrating the issue: https://snack.expo.io/SJ5BLmnVr

You should see the red crash screen when loading that Snack in the device.

image

If you comment out shifting on line 31, the app will run fine and provide a tab bar with a single icon without shifting.

Alternatively, if you uncomment lines 15-16 and 24-25, the app will run fine and provide a tab bar with 3 icons with shifting.

Stale bug low priority

Most helpful comment

On one hand, there is an error but on the other what is the purpose of using a shifting prop with only one tab? WIll this bug appear in the real-world app?

All 4 comments

On one hand, there is an error but on the other what is the purpose of using a shifting prop with only one tab? WIll this bug appear in the real-world app?

Like I said above, probably not, except for someone who is new to the library and just getting started. I wouldn't consider it a high-priority issue.

Yes, we definitely should at least have better error reporting here, especially for newcomers, as you said. Or fix the issue :D

Hello 馃憢, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scottybo picture scottybo  路  3Comments

ButuzGOL picture ButuzGOL  路  4Comments

sritharanpalani picture sritharanpalani  路  4Comments

alikazemkhanloo picture alikazemkhanloo  路  4Comments

kpervin picture kpervin  路  3Comments