In the code below I have SettingsScreen with translations, which works prefectly. I use Android emulator for developing.
import { View, Text } from 'react-native';
import { HeaderBackButton } from 'react-navigation-stack';
import React, { useContext } from 'react';
import { LocalizationContext } from '../components/Translations';
export const SettingsScreen = () => {
const {
translations,
} = useContext(LocalizationContext);
initializeAppLanguage();
return (
<View>
<Text>
{translations['settings.language']}
</Text>
<Text>
{translations['settings.about']}
</Text>
<Text>
{translations['settings.about_content']}
</Text>
</View>
);
};
SettingsScreen.navigationOptions = ({ navigation }) => ({
title: translations['settings.title'],
headerLeft: () => <HeaderBackButton onPress={() => navigation.goBack(null)} />,
});
Now I would like to access translations also from SettingsScreen.navigationOptions, but currently I can not:
title: translations['settings.title']
ReferenceError: translations is not defined
How can I manage to use translations also in navigationOptions?