react native route flux re-render component on stack pop

前端 未结 2 810
悲哀的现实
悲哀的现实 2021-01-23 18:53

How do you re-run React Component Lifecycle methods to determine if a re-render is necessary when transitioning back to previous screens from stack using React Native Router Flu

相关标签:
2条回答
  • 2021-01-23 19:29

    Work Around that works! This workaround seems to be hacky. There must be a better way to hook into component lifecycle to determine if a re-render is required.

    <TouchableHighlight underlayColor='#efefef' onPress={() => { Actions.pop(); setTimeout(()=> Actions.refresh(), 500)}} style={styles.cancel}>
    

    This will call shouldComponentUpdate() method which gives an option to determine, if a re-render is required.

    0 讨论(0)
  • 2021-01-23 19:42

    I was facing the same issue below code gave me required result.

    let count = 0;
    moveToMainScreen = () => {
        count += 1;
        Actions.pop({ refresh: { test: count } });
    };
    
    
    
    <Button onPress={this.moveToMainScreen}> Click </Button>
    
    0 讨论(0)
提交回复
热议问题