Adding event listeners

As it happened with the ShoppingList screen, we want the user to be able to interact with our AddProduct component, so we will add some event handlers to respond to some user actions.

Our render method should then look something like this:

/*** AddProduct.js ***/...render() {  return (    <Container>      <Content>        <List>          { => {            const productIsInList = this.state.productsInList.            find(p => ===;            return (              <ListItem                key={}                onPress={this._handleProductPress.bind                (this, product)}              >                <Body>                  <Text                    style={{ color: productIsInList? '#bbb' : '#000' }}                  >                    {}                  </Text>                 {                   productIsInList &&                   <Text note>                     {'Already in shopping list'}                   </Text>                 }                 </Body>                 <Right>                   <Icon ios="ios-remove-circle" ...

Get React Native Blueprints now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.