-1
Hello!
When I just add Tabnavigator, all icons appear on the tab, however, when I add stackNavigator in the Home.js file, only the first icon (Start) does not appear. I’ve searched some forums and can’t find the problem. Please help me =)
Detail: snack simulator icon does not appear on IOS.
I believe the error is in Home.js or Homelist.js.
Follow the snack link for a better review.
Sorry for the ignorance, I started studying to react native recently.
Hug!
https://snack.expo.io/@israelitalo/fcec5d
App.js
import { createAppContainer } from 'react-navigation';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import 'react-native-gesture-handler';
import Home from './src/Home'
import Contato from './src/Contato'
import Horarios from './src/Horarios'
import Sobre from './src/Sobre'
const TabNavigator = createBottomTabNavigator({
Home: Home,
Contato: Contato,
Horarios: Horarios,
Sobre: Sobre
});
export default createAppContainer(TabNavigator);
Home js.
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import 'react-native-gesture-handler';
import HomeList from './HomeList';
import HomeProducts from './HomeProducts';
const Navegador = createStackNavigator({
HomeList:HomeList,
HomeProducts:HomeProducts
});
export default createAppContainer(Navegador);
Homelist.js
import React, { Component } from 'react';
import { View, Image, StyleSheet, Text } from 'react-native';
export default class HomeList extends Component{
static navigationOptions = {
title:'Restaurante',
tabBarLabel:'Home',
tabBarOptions: {
showIcon: true
},
tabBarIcon:({focused, tintColor})=>{
if(focused){
return(
<Image source={require('../assets/images/home_azul.png')} style={styles.icone}/>
);
}else{
return(
<Image source={require('../assets/images/home_preto.png')} style={styles.icone}/>
);
}
}
};
render(){
return(
<View>
<Text>HomeList</Text>
</View>
);
}
}
const styles = StyleSheet.create({
icone:{
width:26,
height:26
}
});
package json.
[{
"name": "informativo",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.6",
"react": "16.9.0",
"react-native": "^0.61.5",
"react-native-gesture-handler": "^1.5.3",
"react-native-reanimated": "^1.4.0",
"react-native-safe-area-context": "^0.6.2",
"react-native-screens": "^2.0.0-alpha.23",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^2.0.14",
"react-navigation-tabs": "^2.7.0"
},
"devDependencies": {
"@babel/core": "7.8.0",
"@babel/runtime": "7.8.0",
"@react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "6.8.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.56.4",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}[enter image description here][1]
Hello, Bins! All right? I tried to adapt it the way you recommended, but still the Home icon does not appear. Just to let it register, as I mentioned my code up there, the navigation from Tab to Stack is working ok, understand? The problem is that when you go to the Stack screen, the home_blue and home_black icon are not called, do you have any idea why it doesn’t appear, just on the stack navigation screens? Thank you so much for your help. !
– Israel Silva
I was able to make the icon appear, App.js was as follows and Home.js was discarded.
– Israel Silva
const TabNavigator = createAppContainer(
 createBottomTabNavigator(
 {
 Home: { screen: createStackNavigator(
 {
 HomeList,
 HomeProducts 
 },
), navigationOptions: {
 tabBarVisible: true,
 tabBarLabel: 'Home',
 tabBarIcon: ({focused, tintColor}) => (
 <Image source={require('./assets/images/home_azul.png')} style={styles.icone}/>
 ) 
 }},
 Contato,
 Horarios,
 Sobre,
 },
 ),
);
– Israel Silva
In this case, Bins, I need that when the Homelist screen is not "focused", that the home_blue.png icon changes to home_black,png, only that I tried to add Rrow Function and opening {}, but it didn’t work. Do you know if it’s possible with the code the way it is? Thank you, my friend! Sorry for the code above, I could not leave it organized as appeared the option when I opened this topic.
– Israel Silva