spencercarli / react-native-meteor-boilerplate

MIT License
628 stars 139 forks source link

What would be the best way to change the title by passing a parameter? #85

Closed jerocosio closed 7 years ago

jerocosio commented 7 years ago

So I would like to know how to change the title of a screen after using the navigator, so I would like to know where do I need to add this code I got at https://reactnavigation.org/docs/intro#Passing-params

static navigationOptions = ({ navigation }) => ({
    title: `Chat with ${navigation.state.params.user}`,
  });

Thanks in advance!

jerocosio commented 7 years ago

Found it, I fixed with this:

const container = createContainer(({ navigation }) => {
  const handle = Meteor.subscribe('productosCategoria', navigation.state.params._id);
  return {
    name: navigation.state.params.name,
    productsReady: handle.ready(),
    products: Meteor.collection('productos').find() || [],
  };
}, Category);

container.navigationOptions = {
  title: 'Que pedo mamón',
};

export default container;