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
Setting dynamic screen title based on redux state #940
Comments
@hlandao can you give the whole example? where is the state coming from, the one you assign to reduxstate? |
here you go: I'm wrapping each one of the components in a redux container:
|
@tmaly1980 - did you ever figure this out? I'm struggling with the same issue. |
I like @hlandao <https://github.com/hlandao> ’s solution:
<Navigator navigation={addNavigationHelpers({
dispatch: dispatch,
state: nav,
reduxState: state
})} />
Then accessing navigation.reduxState
… On Apr 21, 2017, at 12:31 PM, lorenzsell ***@***.***> wrote:
@tmaly1980 <https://github.com/tmaly1980> - did you ever figure this out? I'm struggling with the same issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#940 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AHVz2x_JK_mrCHRQbi6AKiA5VLDFp1B-ks5ryNn5gaJpZM4M15f_>.
|
@tmaly1980 @hlandao - this method only seems to kind of work for me. I can see the reduxState getting passed to navigationOptions, but unless I explicitly update the state.params, the title itself does not update. So I set title = reduxState.title and nothing happens. But if I call setParams with any kind of dummy data, title = reduxState.title does indeed update. Am I missing something here? |
Hi! Since this issue has been quiet for a while I'm going to go ahead and close it. If the issue persists in the latest version of React Navigation please re-open! |
I was no longer able to get this to work as of 1.0.0-beta.22. so using screenProps instead |
Same here. I want to update the menu items in the contentComponent based on whether the customer is admin or not. I am unable to get this to work with connect() on contentComponent |
@SimonVuong how are you using screenProps? |
I solved this by wrapping Text within a connect call and passing the text to the children prop. A little funky but it works for my use case.
|
its really simple you can make stateless component and connect it with redux like this :
and then use it in static options :
|
Please see this answer for an easier way to do this: https://stackoverflow.com/a/51883306/6942666 |
Try using |
I'm looking to customize a component's title depending on the state in redux, ie show "Sign In" if the user is not logged in (and render() will return a component). Unfortunately, all I have access to is the navigation state, and I don't pass along any user state to the navigate().
For the time being, I have:
This unfortunately causes an infinite loop. I'm tempted to wrap mapStateToProps that also calls props.navigation.setParams.
UPDATE: Unfortunately, even wrapping mapStateToProps, props.navigation.setParams() cannot be called as the state is being changed. Assigning statically to props.navigation.state unfortunately doesn't refresh the title.
The text was updated successfully, but these errors were encountered: