-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
I very much agree with this! It's workaround that is better served by using React features |
Hi! RootNavigator
Screen
Image that instead of this clean and neat code we will have to declare |
@serhiipalash The way you are using If you're concerned with lines of code, you can write your own HOC to address that. Also, it's a state management problem. There is no reason state management solutions should be in a navigation library. |
np, we can do like this
But I understand your arguments that state management is not navigation library problem. Still it would be great if you kept screenProps api |
You can do that, but it's too easy to forget and most of the code I've seen never do it. And even if you do that, whenever the screen props changes, all the screens in the tree are gonna re-render, even if only a few actually use it, not a big deal, but unnecessary. It avoids a little bit of code, yes, but I think being explicit here avoids all the issues associated with this and makes you handle it in a proper way, i.e. with redux, react context or another state management solution. There are other advantages of using context, you can access it in components which aren't screens without having to pass it down manually. |
@serhiipalash - why couldn't you just rewrite the |
Of course I can rewrite it, but it would be the same as I rewrote |
You don't have to rewrite it, you can just create another HOC which gets the user id from context and passes it as a prop. @userIdFromContext
@firebaseConnect(props => [`todos/${props.userId}`])
@connect(state => ({ todos: state.firebase.todos }))
class TodosListScreen extends React.Component {
render() {
const { todos } = this.props
return <div>{todos.map(item => <span key={item.id}>{item.name}</span>)}</div>
}
} |
yes, I was going to do like this, when screenProps will be depricated |
But still, |
If you need global state data in every single route I don't see anything wrong with expecting that every one of those routes will have a HOC to get that data. React Navigation is a navigation library, it shouldn't really be in charge of passing global state. Also honestly, for the specific theme case, depending on your routes it may make more sense for your UI components to be the ones using I suppose the only reasonable counter-argument to this is that direct prop passing is the typical React way, not context which is an advanced extra, and React Navigation is in the way of the App container from directly passing props to the route components within. But even then rather than being the direct passing props to routes, |
I would be so excited to kill |
The only thing preventing the removal of |
Oh, I just though of a use case that isn't handled by #5 and #24 we forgot. We still have a static Although perhaps the solution may be to think of all the possible use cases for default navigation options, then come up with alternative router config options that cover those use cases, and deprecate most of the static navigationOptions. (Then we'd just have navigation config and dynamic options in render()). Some I can think of off the top of my head:
|
Closing since |
No description provided.