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

Allow to hide left button via Actions.refresh #2398

Merged
merged 4 commits into from
Oct 10, 2017

Conversation

onrige
Copy link
Collaborator

@onrige onrige commented Sep 18, 2017

Hide left button on the fly via Actions.refresh by left, leftButton and renderLeftButton properties.

@mention-bot
Copy link

@onrige, thanks for your PR! By analyzing the history of the files in this pull request, we identified @aksonov and @davojan to be potential reviewers.

@@ -188,7 +188,11 @@ function createNavigationOptions(params) {
|| (init ? null : (renderBackButton && renderBackButton(state)) || <BackNavBarButton {...state} />);
}

if (back) {
if (navigationParams.back != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please follow JS standards and use !== instead of != as well as !navigationParams.back instead of === false

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thx. But first one was a typo by the way.

if (back) {
if (typeof navigationParams.back !== 'undefined') {
if (!navigationParams.back) {
res.headerLeft = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd to me, back == false should not hide left button according to API docs.

Proper support for changing back param via Action.refresh would look like this:

if (navigationParams.back || (navigationParams.back !== false && back)) {
  res.headerLeft = (renderBackButton && renderBackButton(state)) || <BackNavBarButton {...state} />;
}

But this will not hide back button in all cases I believe.

Copy link
Collaborator Author

@onrige onrige Sep 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davojan It seems like docs where changed since I did this PR. So I really need this functionality (and may be not only me in future), may be you have some suggestions about this? This add is doing the job I want for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure but I think with my code above Action.refresh({back: false}) should work for you if you haven't defined any of those left-related options for the scene (leftButton, onLeft, leftTitle an so on, see https://github.com/onrige/react-native-router-flux/blob/226f3b645da2b9ef298e57eb2e8296f817880a50/src/navigationStore.js#L182).

If you want to hide left-button (not back-button) I think the right way is left=false or something like that, but back=false doesn't make sense in this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. In my case it's won't work because I'm using leftButton. I think I'll update this PR with hide left functionality instead of back in the evening. Thanks.

@onrige onrige changed the title Allow to hide back button via Actions.refresh Allow to change left button via Actions.refresh Oct 1, 2017
@onrige onrige changed the title Allow to change left button via Actions.refresh Allow to hide left button via Actions.refresh Oct 1, 2017
@aksonov aksonov merged commit 5982353 into aksonov:master Oct 10, 2017
@onrige onrige deleted the feature/hide-back-button branch October 10, 2017 12:19
mvanroon pushed a commit to mvanroon/react-native-router-flux that referenced this pull request Feb 15, 2018
* Allow to hide back button via Actions.refresh

* conditions fixes

* undefined condition fix

* Change left button instead of just hide back
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

Successfully merging this pull request may close these issues.

None yet

5 participants