I would like to know why the code to add a button to the navbar (in V4) is considered an antipattern?
componentDidMount() {
Actions.refresh({
right: () => <TouchableOpacity onPress={this._add}><Text>{"Add"}</Text></TouchableOpacity>
});
}
To me it seems the simplest way to add a button that has a closure to the object into the navbar or am I missing something?
I do it that way and do not get any complaints
<Router>
<Scene key = "root">
<Scene
key = "index"
component = {one}
title = "Whatever"
navigationBarStyle = {styles.header}
titleStyle = {styles.text}
onRight={() => alert("hello")}
rightTitle = {SomeIconComponent}
initial
/>
</Scene>
</Router>
@Paul-Todd It is anti-pattern because you are doing unnecessary 'refresh' (i.e. changing of nav state) when it is not needed. You may try new feature of beta.18 - using Actions.refs.SCENE_NAME to refer to component instance (PR about new docs is welcome).
Most helpful comment
@Paul-Todd It is anti-pattern because you are doing unnecessary 'refresh' (i.e. changing of nav state) when it is not needed. You may try new feature of beta.18 - using
Actions.refs.SCENE_NAMEto refer to component instance (PR about new docs is welcome).