Skip to content

Instantly share code, notes, and snippets.

@vikrantnegi
Created July 8, 2019 10:39
Show Gist options
  • Save vikrantnegi/078d8c5f4bf88bb6b93bbaba2983d590 to your computer and use it in GitHub Desktop.
Save vikrantnegi/078d8c5f4bf88bb6b93bbaba2983d590 to your computer and use it in GitHub Desktop.
export default class App extends React.Component {
constructor(props) {
super(props);
setI18nConfig(); // set initial config
}
componentDidMount() {
RNLocalize.addEventListener("change", this.handleLocalizationChange);
}
componentWillUnmount() {
RNLocalize.removeEventListener("change", this.handleLocalizationChange);
}
handleLocalizationChange = () => {
setI18nConfig();
this.forceUpdate();
};
render() {
return (
<SafeAreaView style={styles.safeArea}>
<Text style={styles.value}>{translate("hello")}</Text>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
safeArea: {
backgroundColor: "white",
flex: 1,
alignItems: "center",
justifyContent: "center"
},
value: {
fontSize: 18
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment