-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
how to perform a function in header? #1468
Comments
A simple way is to store
A better (and of course more complex) way is to use |
@sunnylqm It doesn't work. |
@tom29 My mistake. Simply replace |
is @sunnylqm code considered as good practices? |
Codes of @sunnylqm work, but it doesn't look like a clean way to do so. Any alternatives? |
Hi! In an effort to get the hundreds of issues on this repo under control I'm closing issues tagged as questions. Please don't take this personally - it's simply something we need to do to get the issues to a manageable point. If you still have a question I encourage you to re-read the docs, ask on StackOverflow, or ask on the #react-navigation Reactiflux channel. Thank you! |
You can use
|
| software | version
| react-navigation 1.0.0
| react-native 0.44
| node 7.3
import React from 'react';
import {
AppRegistry,
Text,
Button,
View
} from 'react-native';
import { StackNavigator } from 'react-navigation';
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Welcome',
headerLeft: <Button title='button' onPress={() => {this.changeText()}} //error
/>
};
constructor(props){
super(props)
}
changeText(){
this.setState({ text: '22'})
}
render() {
return (
{this.state.text}
<Button
title='changeText'
onPress={() => {this.changeText()}}
/> //ok
)
}
}
const test = StackNavigator({
Home: { screen: HomeScreen },
});
AppRegistry.registerComponent('test', () => test);
This question is from the previous issues, but the answer is wrong, who can help me ?
The text was updated successfully, but these errors were encountered: