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

renderLeftButton not working when back={true} #3188

Closed
mwskwong opened this issue Aug 18, 2018 · 5 comments
Closed

renderLeftButton not working when back={true} #3188

mwskwong opened this issue Aug 18, 2018 · 5 comments
Assignees
Labels

Comments

@mwskwong
Copy link

mwskwong commented Aug 18, 2018

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.1 (v3 is not supported)
  • react-native v0.55.4

Expected behaviour

Action.refresh({
    left: <LeftButton />
});

should override the back button and display the custom <LeftButton/> component in any case.

Actual behaviour

This doesn't happen IF AND ONLY IF

<Scene
    back={true}
/>

I have also tried:

Action.refresh({
    renderBackButton: <LeftButton />
});

Action.refresh({
    back: <LeftButton />
});

Action.refresh({
    renderBackButton: () => <LeftButton />
});

Action.refresh({
    back: () => <LeftButton />
});

Action.refresh({
    renderLeftButton: <LeftButton />
});

And none of above works.

Note, the back button still appear and takes effect when back is not specified (of course it will be hidden if back={false})

@daviscabral
Copy link
Collaborator

I don't think it works like that with refresh - but I'll check it and get back to you.

@mwskwong
Copy link
Author

Basically, this is what I'm trying to do:

I have to allow user to select multiple items and delete them, similar to the file manager. You have a delete button on the right, when clicked, the left button will be replaced with a "select all" check box. If the user press cancel or confirm, the left button will be reverted back to a normal "back" button.

This is the only way I can think of doing it. Please feel free to suggest any better solution, if this is not how it suppose to do.

@daviscabral
Copy link
Collaborator

@matthewkwong2 for params, that's correct, it is renderLeftButton - but since back was true - it seems it is being replaced right after being set.

@aksonov
Copy link
Owner

aksonov commented Sep 5, 2018

@matthewkwong2 It looks like a hack and probably just not supported by React Navigation 2.x (its SET_PARAMS action). Instead you should define one renderLeftButton that changes its content depending from navigation state. Actions.refresh should be used just to update navigational state (i.e. pass values not functions)

@aksonov aksonov closed this as completed Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants