withLocalize breaks navigationOptions for react-navigation
See original GitHub issueBug
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:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Proposed solution seems to solve the problem. It works at least in my projects and hopefully for others as well.
Fixed in #130 and published in
v3.5.0
.