enter image description here
These createBottomTabNavigator icons not showing when i run in my device, but icons are showing when i run using web?
what i need add to show createBottomTabNavigator icons. can anyone suggest me.
here this is App.js code from my project. i used
import * as React from 'react';
import 'react-native-gesture-handler';
import { createBottomTabNavigator } from '#react-navigation/bottom-tabs';
import { NavigationContainer } from '#react-navigation/native';
import { createStackNavigator } from '#react-navigation/stack';
import Index from "./pages/Index";
import Home from "./pages/Home";
import LogIn from "./pages/LogIn";
import Register from "./pages/Register";
import CplusBooks from "./pages/CplusBooks";
import PhpBooks from "./pages/PhpBooks";
import DotNetBooks from "./pages/DotNetBooks";
import SearchBooks from "./pages/SearchBooks";
const Tab = createBottomTabNavigator();
const stack = createStackNavigator();
export default () => (
<NavigationContainer>
<stack.Navigator>
<stack.Screen
name="Index"
component={Index}
options={{headerShown: false}}
/>
<stack.Screen
name="Home"
component={HomeTab}
options={{headerShown: false}}
/>
<stack.Screen
name="LogIn"
component={LogIn}
options={{headerShown: false}}
/>
<stack.Screen
name="Register"
component={Register}
options={{headerShown: false}}
/>
<stack.Screen
name="CplusBooks"
component={CplusBooks}
options={{headerShown: false}}
/>
<stack.Screen
name="PhpBooks"
component={PhpBooks}
options={{headerShown: false}}
/>
<stack.Screen
name="DotNetBooks"
component={DotNetBooks}
options={{headerShown: false}}
/>
</stack.Navigator>
</NavigationContainer>
);
It must be a problem with react-native-vector-icons Try this steps
Open android/app/build.gradle and add the following:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
You can follow the instructions to properly install the module on Android: react-native-vector-icons#install-android
First, make sure you're saving the dependency in your project by doing:
npm install react-native-vector-icons --save. Including the --save is necessary, otherwise react-native link won't be able to locate the module.
Related
I'm very new to react native.. very much still learning. I read the docs for react navigation but I can't get my bottom tab navigator to display. I run the project and it loads up just fine without any errors or warnings but my bottom tab navigation won't display. I'm not really sure where to start.. Below is a copy of what I wrote so far. This is written in a separate .js named tabnavigator.js
import {createBottomTabNavigator} from '#react-navigation/bottom-tabs';
import Dashboard from './src/screens/Dashboard';
import Agencyhome from './src/screens/Agencyhome';
const Tab = createBottomTabNavigator ();
const TabNavigator = () => {
return (
<Tab.Navigator>
<Tab.Screen name='Home' component={Dashboard} />
<Tab.Screen name="Agency" component={Agencyhome} />
</Tab.Navigator>
);
}
export default TabNavigator;
Here is what I have for my App.js
import React from 'react'
import { Provider } from 'react-native-paper'
import { NavigationContainer } from '#react-navigation/native'
import { createStackNavigator } from '#react-navigation/stack'
import firebase from 'firebase/app'
import 'firebase/auth'
import { theme } from './src/core/theme'
import {
AuthLoadingScreen,
StartScreen,
LoginScreen,
RegisterScreen,
ResetPasswordScreen,
Dashboard,
} from './src/screens'
import { FIREBASE_CONFIG } from './src/core/config'
const Stack = createStackNavigator()
if (!firebase.apps.length) {
firebase.initializeApp(FIREBASE_CONFIG)
}
export default function App() {
return (
<Provider theme={theme}>
<NavigationContainer>
<Stack.Navigator
initialRouteName="AuthLoadingScreen"
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen
name="AuthLoadingScreen"
component={AuthLoadingScreen} />
<Stack.Screen name="StartScreen" component={StartScreen} />
<Stack.Screen name="LoginScreen" component={LoginScreen} />
<Stack.Screen name="RegisterScreen" component={RegisterScreen} />
<Stack.Screen name="Dashboard" component={Dashboard} />
<Stack.Screen name="ResetPasswordScreen" component={ResetPasswordScreen} />
</Stack.Navigator>
</NavigationContainer>
</Provider>
)
}
you must use Navigation Container
like this
import { NavigationContainer } from "#react-navigation/native";
import {createBottomTabNavigator} from '#react-navigation/bottom-tabs';
import Dashboard from './src/screens/Dashboard';
import Agencyhome from './src/screens/Agencyhome';
const Tab = createBottomTabNavigator ();
const TabNavigator = () => {
return (
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen name='Home' component={Dashboard} />
<Tab.Screen name="Agency" component={Agencyhome} />
</Tab.Navigator>
</NavigationContainer>
);
}
export default TabNavigator;
I was able to fix this by using the following component={TabNavigator} within stackscreen
I am using React Native Navigation version 6 in my project. A white background flashes when switching between screens. Only stack navigator has this problem. I did not encounter this problem on iOS.
My Stack Navigator
import React from 'react';
import {createNativeStackNavigator} from '#react-navigation/native-stack';
import Login from '../screens/Login';
import Register from '../screens/Register';
import ForgotPassword from '../screens/ForgotPassword';
import {NavigationContainer, DefaultTheme} from '#react-navigation/native';
import {View} from 'react-native'
const Stack = createNativeStackNavigator();
const SignedOutStack = () => {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false,
}}>
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="Register" component={Register} />
<Stack.Screen name="ForgotPassword" component={ForgotPassword} />
</Stack.Navigator>
</NavigationContainer>
);
};
export default SignedOutStack;
You can change the stack background with cardStyle option. See here.
I am now using the Expo-cli for react-native developing
Since I am gonna set my first page as Homepage but now it is setted as login page
import * as React from 'react';
import {NavigationContainer} from '#react-navigation/native';
import {createStackNavigator} from '#react-navigation/stack';
import Splash from './pages/splash';
import AuthLogin from './pages/auth/Login';
import AuthRegister from './pages/auth/Register';
import AuthRecoverPassword from './pages/auth/RecoverPassword';
import Home from './pages/home/home'
import Profile from './pages/profile/profile'
const Stack = createStackNavigator();
function App() {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false,
}}>
<Stack.Screen name="Splash" component={Splash} />
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="AuthLogin" component={AuthLogin} />
<Stack.Screen name="AuthRegister" component={AuthRegister} />
<Stack.Screen
name="AuthRecoverPassword"
component={AuthRecoverPassword}
/>
<Stack.Screen name="Profile" component={Profile} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;
Also hope you to let me know about the Stack.screen feature.
function App() {
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName='Home' ///the name of the initial screen
screenOptions={{
headerShown: false,
}}>
<Stack.Screen name="Splash" component={Splash} />
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="AuthLogin" component={AuthLogin} />
<Stack.Screen name="AuthRegister" component={AuthRegister} />
<Stack.Screen
name="AuthRecoverPassword"
component={AuthRecoverPassword}
/>
<Stack.Screen name="Profile" component={Profile} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;
I am still trying to figure out how to create independent tab bar and drawer Navigation in React Native.
The drawer navigation should display for example
Screen01
Screen02
Screen03
Screen04
Screen05
whereas the tab bar navigation should only display
Screen01
Screen03
Screen05.
I already have a drawer/tab bar navigation combination working, but I was not able to make it work independent yet. Every screen is visible for both navigation types.
If you want to see the code, let me know :) Thank you in advance!
EDIT:
This is my code using Erik's answer.
import React from 'react';
import { createDrawerNavigator } from '#react-navigation/drawer'
import { createStackNavigator } from '#react-navigation/stack'
import { createBottomTabNavigator } from '#react-navigation/bottom-tabs';
import HomeScreen from './Components/Screens/HomeScreen'
import SearchScreen from './Components/Screens/SearchScreen'
import FavoritesScreen from './Components/Screens/FavoritesScreen'
import ProfileScreen from './Components/Screens/ProfileScreen'
import FAQScreen from './Components/Screens/FAQScreen'
import SettingsScreen from './Components/Screens/SettingsScreen'
const Tab = createBottomTabNavigator();
const Drawer = createDrawerNavigator();
const Stack = createStackNavigator();
const container = createAppContainer(Stack)
function TabScreens() {
return (
<Tab.Navigator>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Search" component={SearchScreen} />
<Tab.Screen name="Favorites" component={FavoritesScreen} />
</Tab.Navigator>
);
}
function DrawerScreens() {
return (
<Drawer.Navigator>
<Drawer.Screen name="Profile" component={ProfileScreen} />
<Drawer.Screen name="FAQ" component={FAQScreen} />
</Drawer.Navigator>
);
}
export default function App() {
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={TabScreens} />
<Stack.Screen name="Drawer" component={DrawerScreens} />
<Stack.Screen name="Settings" component={SettingsScreen} />
</Stack.Navigator>
);
}
I am new to react native and I am trying to create a menu, that would open on click and slide out, and on click outside the menu would slide back in.
It has been very hard for me to find any decent tutorial/explanation about how to have both stack and drawer navigation available for a page and functioning.
currently, my App.js looks like this:
import 'react-native-gesture-handler';
import React from 'react';
import Home from './app/screens/Home/Home';
import ArtistListing from './app/screens/ArtistListing/ArtistListing';
import ArtPeriods from './app/screens/ArtPeriods/ArtPeriods';
import Login from './app/screens/Login/Login';
import Quiz from './app/screens/Quiz/Quiz';
import GuessWhen from './app/screens/GuessWhen/GuessWhen';
import { NavigationContainer, useLinking } from '#react-navigation/native';
import { createStackNavigator } from '#react-navigation/stack';
import {Auth, Hub} from 'aws-amplify';
import {SetCurrentUser} from './src/model/User';
import LearnMore from './app/screens/LearnMore/LearnMore';
import {CreateAllArtistsWithDependencies} from './src/model/Artists';
import ExploreTimePeriod from './app/screens/ExploreTimePeriod/ExploreTimePeriod';
import ExploreArtist from './app/screens/ExploreArtist/ExploreArtist';
import PhotoGalleryScreen from './app/screens/PhotoGalleryScreen/PhotoGalleryScreen';
import ExploreTimePeriods from './app/screens/ExploreTimePeriods/ExploreTimePeriods';
import ExploreArtists from './app/screens/ExploreArtists/ExploreArtists';
import QuizSummary from './app/screens/QuizSummary/QuizSummary';
import ContactUs from './app/screens/ContactUs/ContactUs';
import Profile from './app/screens/Profile/Profile';
import Favorites from './app/screens/Favorites/Favorites';
const Stack = createStackNavigator();
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Login">
<Stack.Screen name="Home" component={Home} options={{headerShown:false}} />
<Stack.Screen name="Login" component={Login} options={{headerShown:false}} />
<Stack.Screen name="ArtistListing" component={ArtistListing} options={{headerShown:false}}/>
<Stack.Screen name="ArtPeriods" component={ArtPeriods} options={{headerShown:false}}/>
<Stack.Screen name="GuessWhen" component={GuessWhen} options={{headerShown:false}}/>
<Stack.Screen name="Quiz" component={Quiz} options={{headerShown:false}}/>
<Stack.Screen name="LearnMore" component={LearnMore} options={{headerShown:false}}/>
<Stack.Screen name="ExploreTimePeriod" component={ExploreTimePeriod} options={{headerShown:false}}/>
<Stack.Screen name="ExploreTimePeriods" component={ExploreTimePeriods} options={{headerShown:false}}/>
<Stack.Screen name="PhotoGalleryScreen" component={PhotoGalleryScreen} options={{headerShown:false}}/>
<Stack.Screen name="ExploreArtist" component={ExploreArtist} options={{headerShown:false}}/>
<Stack.Screen name="ExploreArtists" component={ExploreArtists} options={{headerShown:false}}/>
<Stack.Screen name="QuizSummary" component={QuizSummary} options={{headerShown:false}}/>
<Stack.Screen name="ContactUs" component={ContactUs} options={{headerShown:false}}/>
<Stack.Screen name="Profile" component={Profile} options={{headerShown:false}}/>
<Stack.Screen name="Favorites" component={Favorites} options={{headerShown:false}}/>
</Stack.Navigator>
</NavigationContainer>
);
};
export default App;
I would like to have a drawer navigator as well with the pages listed below. I know I might need a switch navigator, but everything is super hard to find for version 5. I bet I am not the only one searching for a clear answer on how to do this.
<Drawer.Screen name="ContactUs" component={ContactUs} options={{headerShown:false}}/>
<Drawer.Screen name="Profile" component={Profile} options={{headerShown:false}}/>
<Drawer.Screen name="Favorites" component={Favorites} options={{headerShown:false}}/>
If you have an idea about this, please give me a suggestion.
Let'say your stack after login like
const Stack = createStackNavigator();
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={Home} options={{headerShown:false}} />
<Stack.Screen name="ArtistListing" component={ArtistListing} options={{headerShown:false}}/>
</Stack.Navigator>
</NavigationContainer>
);
};
Let's say this is your drawer navigation.
const Drawer = createDrawerNavigator();
function drawers(){
<Drawer.Screen name="Home" component={App} options={{headerShown:false}}/>
<Drawer.Screen name="ContactUs" component={ContactUs} options={{headerShown:false}}/>
<Drawer.Screen name="Profile" component={Profile} options={{headerShown:false}}/>
}
Now Drawer will be everywhere by default. And HomeScreen will be your first screen by default.
Now the part of AuthFlow.
const AuthFlowStack = createStackNavigator();
function AuthFlow(){
<AuthFlow.Screen name='LogIn' component={LogIn} />
}
Main Stack Flow(which will act as SwitchNavigator)
const Main = createStackNavigator();
function MainFlow(){
{this.state.isLogin ? <Drawer/> :<AuthFlow/>}
}
export default {MainFlow};
And set the value of isLogin to true when you login and send as parameter and set it false when logout.