react-native-navigation
How to trigger an event when a component is shown when using react-native-navigation?
I like the solution proposed by Bruno Reis. I tweaked mine to make it a bit simpler. class Whatever extends Component { componentDidMount(){ this.load() this.props.navigation.addListener(‘willFocus’, this.load) } load = () => { … } }
Refresh previous screen on goBack()
Adding an Api Call in a focus callBack in the screen you’re returning to solves the issue. componentDidMount() { this.props.fetchData(); this.willFocusSubscription = this.props.navigation.addListener( ‘willFocus’, () => { this.props.fetchData(); } ); } componentWillUnmount() { this.willFocusSubscription.remove(); } UPDATE 2023: willFocus event was renamed to focus componentDidMount() { this.props.fetchData(); this.focusSubscription = this.props.navigation.addListener( ‘focus’, () => { this.props.fetchData(); } … Read more
Getting this error: error: bundling failed: Error: Unable to resolve module `react-native-safe-area-context`
I think the problem is in the SafeAreaView, for the new react-native version, it has migrated to react-native-community/react-native-safe-area-view. if you want to use SafeAreaView, you should install it first. the new use is like this: import SafeAreaView from ‘react-native-safe-area-view’; export default function MyAwesomeApp() { return ( <SafeAreaView style={{ flex: 1 }}> <View style={{ flex: 1 … Read more
React Navigation vs. React Native Navigation [closed]
NEW EDIT: As of today (07/2020) I suggest using React Navigation v5. It’s the community solution being most pushed by Facebook. The V5 rewrite was a complete game changer and is far superior to previous versions. Easy to get setup and implementing easy/complicated stacks is a breeze most of the time. If that’s not doing … Read more