bns
bns

Reputation: 397

React native navigator memory can't release

My application is using navigatorios. Whenever new scene push to the stack, it didn't release memory. It seems intuitive, cause it allowing you to pop it back to previous route. I tried to use replace instead of push, however, the title won't change.

Is there any workaround on my case? Requiremnent: Change the title on every route

Edit:

In my application, there are several sections and for each section has different navigator title.

<NavigatorIOS
    ref='nav'
    initialRoute={{
    component: component,
    title: title,
    }}
/>

To change the title, i use push to show next section. Memory meter in xcode showing it's using more and more.

this.refs.nav.push({
    component: component,
    title: title,
    });

Answer

Finally changed to use Navigator instead of NavigatorIOS. Using replace instead of push.

Upvotes: 0

Views: 545

Answers (1)

J.Doe
J.Doe

Reputation: 1137

can you show your code here so that we can diagnose your problem thoroughly?

anyhow, changing title on every route is easy with Navigator, in your root Navigator component, define your routes.

const routes = {
  Movies,
  Contact
};

Create a custom component inside your renderScene method

renderScene(route, navigator) {
    let Component = routes[route.name];
    return <Component navigator={navigator} {...route.passProps}/>
  }

As you can see the renderScene method passes some props and this is the place you pass your title to the next screen.

Hope it helps!

Upvotes: 0

Related Questions