question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

withLocalize breaks navigationOptions for react-navigation

See original GitHub issue

Bug

When I use withLocalize on a screen component together with react-navigation, static navigationOptions is no longer called.

This works and the title is shown

class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'Home',
  };

  render() {
    return (
      <ScrollView>         
         <Button 
             onPress={() => null}
             title={this.props.translate('home.login')}
             <!-- Of course this only works when withLocalize is used -->
      </ScrollView>
    );
  }
}
export default HomeScreen;

but when I use export default withLocalize(HomeScreen); navigationOptions is not called and the title is not displayed. Everything else works well and the translations are shown.

I have my own project but have also tried with a default expo tab template project and experience the same problem.

Maybe it’s not that much help but you can see the app here. The Links screen is with withLocalize and the Settings screen without.

"dependencies": {
    "@expo/samples": "2.1.1",
    "expo": "29.0.0",
    "react": "16.3.1",
    "react-localize-redux": "^3.3.2",
    "react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
    "react-navigation": "^2.9.3",
    "redux": "^4.0.0"
},

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
andyhbgcommented, Aug 31, 2018

Proposed solution seems to solve the problem. It works at least in my projects and hopefully for others as well.

0reactions
ryandrewjohnsoncommented, Oct 17, 2018

Fixed in #130 and published in v3.5.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

navigation-options
This is documentation for React Navigation 1.x, which is no longer actively maintained. For up-to-date documentation, see the latest version (6.x).
Read more >
React navigation broken within function call - Stack Overflow
In login , you're declaring a function but neither invoking it or assigning it to anything: () => this.props.navigation.navigate('Home');.
Read more >
getting-started – React Localize Redux Documentation
For your component to have access to the initialize prop you'll need to use the withLocalize higher-order component. Add translation data. To add...
Read more >
React Native Navigation: Tutorial with examples
React Navigation is one of the most well-known navigation ... stated that the latest release brings in very few breaking changes this time....
Read more >
How to use the react-navigation.createStackNavigator function ...
To help you get started, we've selected a few react-navigation. ... screen: ModalCastConnect, navigationOptions: { gesturesEnabled: false } } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found