You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is expected behavior. In ES7 you'll likely be able to use a property initializer to write
onPress = () => {
// ...
}
which will autobind. This syntax is supported by Babel already in an experimental transform and hopefully will be supported in react-native sometime. You can continue to use React.createClass if you prefer its semantics.
When creating a component 'ES6-style' (e.g.
class Card extends React.Component
), event callbacks will not automatically bind scope.In the following example, I had to replace
onPress={this.onPress}
with
onPress={this.onPress.bind(this)}
.Using React Native 0.3.11
The text was updated successfully, but these errors were encountered: