akveo / kittenTricks

React Native starter kit with over 40 screens and modern Light and Dark theme for creating stunning cross-platform mobile applications.
https://akveo.github.io/react-native-ui-kitten/
MIT License
7.17k stars 986 forks source link

fix: remove warnings #318

Closed whitestranger7 closed 3 years ago

whitestranger7 commented 3 years ago

Please read and mark the following check list before creating a pull request:

Blocked by #316

github-actions[bot] commented 3 years ago

Try running it on Mobile

.

artyorsh commented 3 years ago

Also resolved in #316

whitestranger7 commented 3 years ago

Also resolved in #316

I dont see tabNavigaton fix in #316. Let's merge #316 first and then merge this pr to master

jcjveraa commented 3 years ago

Also resolved in #316

I dont see tabNavigaton fix in #316. Let's merge #316 first and then merge this pr to master

For me the getFocusedRouteNameFromRoute(route); doesn't work - it returns undefined always. I think it should work, but it doesn't. Maybe you use Navigator differently than they think? This propsed fix gets rid of the warning, but doesn't solve the problem - it does not hide the menu.

What does work: simply use const currentRoute: string = route.name; (and the isOneOfRootRoutes change)

full code that works for me & hides the bottom bar:

const isOneOfRootRoutes = (currentRoute: string): boolean => {
  return ROOT_ROUTES.find(root_route => currentRoute === root_route) !== undefined;
};

const TabBarVisibleOnRootScreenOptions = ({ route }): BottomTabNavigationOptions => {
  const currentRoute: string = route.name;
  return { tabBarVisible: currentRoute && isOneOfRootRoutes(currentRoute) };
};
artyorsh commented 3 years ago

@jcjveraa

Thanks for chipping in. Just one proposal here: we can use double negation instead of explicit undefined check.

const isOneOfRootRoutes = (currentRoute: string): boolean => {
-  return ROOT_ROUTES.find(route => currentRoute === route) !== undefined;
+ return !!ROOT_ROUTES.find(route => currentRoute === route);
};

const TabBarVisibleOnRootScreenOptions = ({ route }): BottomTabNavigationOptions => {
  const currentRoute: string = route.name;
  return { tabBarVisible: currentRoute && isOneOfRootRoutes(currentRoute) };
};