the code that shows in the part below is for the version of react-navigation 2.x
you can try the following:
in my case I have the configuration of navigation in a file called, app-navigator.js
const ChatStackNavigator = createStackNavigator(
{
People: ListPeopleScreen, // People Screen,
Screen2: Screen2
},
{
initialRouteName: 'People'
navigationOptions: ({navigation}) => ({
header: <AppBar title={navigation.getParam('appBar', {title: ''}).title}/>
}),
cardStyle: {
backgroundColor: 'white'
}
}
);
The screen file would be as follows:
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {List, ListItem} from 'react-native-elements';
class ListPeopleScreen extends Component {
list = [
{
name: 'Amy Farha',
avatar_url: 'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg',
subtitle: 'Vice President'
},
{
name: 'Chris Jackson',
avatar_url: 'https://s3.amazonaws.com/uifaces/faces/twitter/adhamdannaway/128.jpg',
subtitle: 'Vice Chairman'
}
];
componentDidMount() {
this.props.navigation.setParams({
appBar: {
title: 'Clientes'
}
});
}
render() {
return <List
containerStyle={{marginBottom: 30}}
>
{
this.list.map((item) => (
<ListItem
roundAvatar
avatar={{uri: item.avatar_url}}
key={item.name}
title={item.name}
/>
))
}
</List>
};
}
export default connect(null)(ListPeopleScreen);
NOTE: in my case I am using redux, and the library of components react-native-elements