O'Reilly logo

React Native Blueprints by Emilio Rodriguez Martinez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding event handlers 

All the interaction with the user will happen through event handlers in React Native. Depending on the controller, we will have different events which can be triggered. The most common event is onPress, as it will be triggered every time we push a button, a checkbox, or a view in general. Let's add some onPress handlers for all the components which can be pushed in our screen:

/*** ShoppingList.js ***/...render() { return (   <Container>     <Content>       <List>        {this.state.products.map(p => {          return (            <ListItem              key={p.id}              onPress={this._handleProductPress.bind(this, p)}            >              <Body>                <Text style={{ color: p.gotten ? '#bbb' : '#000' }}>                  {p.name}                </Text>              </Body>              <Right>                <CheckBox                  checked={p.gotten} onPress={this._handleProductPress.bind(this, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required