React navigation goBack() and update parent state

You can pass a callback function as parameter when you call navigate like this: const DEMO_TOKEN = await AsyncStorage.getItem(‘id_token’); if (DEMO_TOKEN === null) { this.props.navigation.navigate(‘Login’, { onGoBack: () => this.refresh(), }); return -3; } else { this.doSomething(); } And define your callback function: refresh() { this.doSomething(); } Then in the login/registration view, before goBack, you … Read more

Setting environment variable in react-native?

Instead of hard-coding your app constants and doing a switch on the environment (I’ll explain how to do that in a moment), I suggest using the twelve factor suggestion of having your build process define your BASE_URL and your API_KEY. To answer how to expose your environment to react-native, I suggest using Babel’s babel-plugin-transform-inline-environment-variables. To … Read more

What is the difference between Expo and React Native?

When you write code in Expo you are writing React Native code. Expo has two main pieces: Expo CLI (expo-cli): a developer tool for creating projects, viewing logs, opening on your device, publishing, etc. Expo client: an app on your phone that lets you open your projects while you’re working on them, without needing to … Read more