-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
src/navigationStore.js
Outdated
@@ -188,7 +188,11 @@ function createNavigationOptions(params) { | |||
|| (init ? null : (renderBackButton && renderBackButton(state)) || <BackNavBarButton {...state} />); | |||
} | |||
|
|||
if (back) { | |||
if (navigationParams.back != null) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/navigationStore.js
Outdated
if (back) { | ||
if (typeof navigationParams.back !== 'undefined') { | ||
if (!navigationParams.back) { | ||
res.headerLeft = null; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
* Allow to hide back button via Actions.refresh * conditions fixes * undefined condition fix * Change left button instead of just hide back
Hide left button on the fly via Actions.refresh by
left
,leftButton
andrenderLeftButton
properties.