I have a problem with TabNavigator ... I would like to pass a parameter in my navigation put i try hard and nothing :(
navigation.js
import React, { Component } from 'react';
import { TabNavigator } from 'react-navigation';
import ListingScreen from './listing';
import PreferencesScreen from './preferences';
import AddScreen from './add';
import CalendarScreen from './calendar';
import ProfessionalScreen from './professional';
const navigation = TabNavigator({
Listing: {screen: ListingScreen},
Preferences: {screen: PreferencesScreen, screenProps: {option: "My first option"}},
Add: {screen: AddScreen},
Calendar: {screen: CalendarScreen},
Professional: {screen: ProfessionalScreen},
}, {
tabBarOptions: {
activeTintColor: 'blue',
activeBackgroundColor: 'grey',
inactiveTintColor: 'black',
},
});
<navigation
screenProps="I am a Props !"
/>
export default navigation;
My others screens : (They are identical) preferences.js
import React, { Component } from 'react';
import {View, Text} from 'react-native';
export default class Preferences extends Component {
static navigationOptions = {
title: 'Preferences',
};
constructor(props) {
super(props);
console.log("Constructor");
console.log(this.props)
}
render() {
return (
<View>
<Text style={{marginTop: '80%', marginLeft: '40%'}}> Preferences </Text>
</View>
);
}
}
In my constructor I try to display the props but I have that ...
Someone know use that ?
Try this:
import React, { Component } from 'react';
import { TabNavigator } from 'react-navigation';
import PreferencesScreen from './preferences';
const Navigation = TabNavigator({
Preferences: {screen: PreferencesScreen},
}, {
tabBarOptions: {
activeTintColor: 'blue',
activeBackgroundColor: 'grey',
inactiveTintColor: 'black',
},
});
export default class Index extends Component {
render() {
return <Navigation screenProps="I am a Props !"/>;
}
}