-3

I will be very happy if you can help me. I am making react native expo app. I have code that displays information from the database. But i want convert this code from arrow functions to normal function.

<View>
        <ListView
          dataSource={this.state.dataSource}
          renderSeparator= {this.ListViewItemSeparator}
          renderRow={(rowData) =>
            <Text
                      onPress={() => {
                        /* 1. Navigate to the Details route with params */
                        this.props.navigation.navigate('Details', {
                          otherParam: rowData.article_title,
                        });
                      }}
                    >{rowData.article_title}</Text>
      }
        />
</View>

I want to have something like this, but i do not know how to do this:

<View>
     <Text
       onPress={() => {
             /* 1. Navigate to the Details route with params */
                 this.props.navigation.navigate('Details', {
                    otherParam: rowData.article_title,
              });
          }}
        >{rowData.article_title}</Text>
      }
</View>
VLAZ
  • 26,331
  • 9
  • 49
  • 67
Rapprogtrain
  • 135
  • 2
  • 14

1 Answers1

0
onPress(() => { /* some code */})

Is equivalent to

function doOnPress() {
/* some code */
}

onPress(doOnPress.bind(this))
MrD
  • 4,986
  • 11
  • 48
  • 90