Skip to content

componentWillMount called more than once, componentWillUnmount not called on scene change #335

@liangmicha

Description

@liangmicha

Hi all, I am running into an issue with react-native-router-flux where componentWillMount for one of my components is being called more than once.

I am using react-native-router-flux: "^2.3.12"

so if I switch from Component1 (Groceries) to Component 2 (Detail) and switch back to Component1, componentWillMount for Component1 is called again for that first component.

I have some important listeners that I don't want to register twice in componentWillMount

and for some reason componentWillUnmount isn't called either

I am using redux, anyone have this issue also?

Here's my code snippet of my two tabs (tabbarGrocerties and tabberDetail)

class Application extends Component {
  render() {
    return (
          <Router hideNavBar={true} name="root">

              <Schema name="withoutAnimation"/>

              <Route name="signin" component={SignIn} title="Register"/>
              <Route name="tabbar">
                  <Router footer={TabBar} hideNavBar={true}>
                      <Route name="tabbarGroceries" schema="tab" title="Groceries TODO" component={Groceries} hideTabBar={true}/>
                      <Route name="tabbarDetail" schema="tab" title="Detail" component={Detail} />
                  </Router>
              </Route>
          </Router>
    );
  }
}

Groceries render contains:

<Text onPress={Actions.tabbarDetail}> Click here to go to detail </Text>

Detail.js render contains

<Text onPress={Actions.tabbarGroceries}>Click to go to groceries</Text>

Both Action is imported like this:

var Actions = require('react-native-router-flux').Actions;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions