Created
July 8, 2019 10:39
-
-
Save vikrantnegi/078d8c5f4bf88bb6b93bbaba2983d590 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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