We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
page1 componentWillReceiveProps called once when page2 pop to page1.
componentWillReceiveProps
page1 componentWillReceiveProps infinite loop when page2 pop to page1.
git clone https://github.com/ekoooo/TestRouterFlux.git
page2 componentWillMount page2 componentWillUnmount page1 componentWillReceiveProps page2 componentWillMount page2 componentWillUnmount page1 componentWillReceiveProps page2 componentWillMount page2 componentWillUnmount page1 componentWillReceiveProps page2 componentWillMount page2 componentWillUnmount page1 componentWillReceiveProps page2 componentWillMount page2 componentWillUnmount page1 componentWillReceiveProps page2 componentWillMount page2 componentWillUnmount ... ... ...
import React, { Component } from 'react'; import { Text, View, TouchableOpacity, } from 'react-native'; import { Actions } from 'react-native-router-flux'; export default class Page1 extends Component { constructor(props) { super(props); this.state = { }; } componentWillReceiveProps(newProps) { console.log('page1 componentWillReceiveProps'); } render() { return ( <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> <TouchableOpacity onPress={() => { Actions.page2() }}> <Text>go page2</Text> </TouchableOpacity> </View> ); } }
import React, { Component } from 'react'; import { Text, View, YellowBox, TouchableOpacity, } from 'react-native'; import { Actions } from 'react-native-router-flux'; YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']); export default class Page1 extends Component { constructor(props) { super(props); this.state = {}; this.timer = null; this._delayGoback = this._delayGoback.bind(this); } componentWillMount() { console.log('page2 componentWillMount'); Actions.refresh({ rightTitle: "comfirm", onRight: () => { }, }) } componentWillUnmount() { console.log('page2 componentWillUnmount'); this.timer && clearTimeout(this.timer); } _delayGoback() { this.timer = setTimeout(() => { Actions.pop({ refresh: { updateList: true, d: +new Date(), } }); }, 200); } render() { return ( <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> <TouchableOpacity onPress={() => { this._delayGoback() }}> <Text>pop</Text> </TouchableOpacity> </View> ); } }
The text was updated successfully, but these errors were encountered:
You need to use setTimeout to defer nav action
setTimeout
Sorry, something went wrong.
No branches or pull requests
Version
Expected behaviour
page1
componentWillReceiveProps
called once when page2 pop to page1.Actual behaviour
page1
componentWillReceiveProps
infinite loop when page2 pop to page1.Steps to reproduce
git clone https://github.com/ekoooo/TestRouterFlux.git
.logs
Code
page1
page2
The text was updated successfully, but these errors were encountered: