Skip to content
New issue

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

Change the nav title without re-rendering #3065

Closed
nica0012 opened this issue Jun 5, 2018 · 4 comments
Closed

Change the nav title without re-rendering #3065

nica0012 opened this issue Jun 5, 2018 · 4 comments

Comments

@nica0012
Copy link

nica0012 commented Jun 5, 2018

Hi all,

Is it possible to change the nav title without re-rendering?

I am currently using this, which works:

  if (event.nativeEvent.contentOffset.y > 20) {
      Actions.refresh({ title: this.props.title) });
    } else {
      Actions.refresh({ title: 'Specs' });
    }

The problem is there is animation taking place during this switch - when the switch happens it lags the whole animation. I even tried to do the switch before and after the animation but it still lags it.

Cheers.

@daviscabral
Copy link
Collaborator

I think this might be possible only if you use a custom smart Header (that might get an action and trigger its re-render - without re-rendering the rest of the page).

A different alternative, hacky way, in case you are working with a sort of scrolling title replacement, it's to use conditional styles to apply the title over the Header (covering the header title).

Have you tried to disable the animations before updating the title?

@nica0012
Copy link
Author

nica0012 commented Jun 5, 2018

@daviscabral Thanks for the feedback! I just tried to use redux to dispatch an action (new title) to the router component after the scrollview reaches the title switch point, but this is causing the whole screen to re-render which causes the scroll to start over... I have also tried removing the title and then using absolute positioning to place my own over it like you mentioned, but i can't seem to over ride the zIndex value of the RNRF navbar.

Can you tell me more about this custom smart header? I thought using redux on the router component would do the trick, it caused the title to change but its causing a re-render on everything - maybe because its the overall wrapper?

@aksonov
Copy link
Owner

aksonov commented Aug 8, 2018

You may pass React component as header (i.e. smart header) that will listen for some redux/mobx events and changes the title.

@aksonov aksonov closed this as completed Aug 8, 2018
@kuriel-trivu
Copy link

kuriel-trivu commented Oct 6, 2021

Why the default Header is not smart by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants