I have a listview in index.js
my react native project like below.
import ResultRow from './resultRow'
class ResultList extends Component {
constructor() {
}
updateDate(){
//Some operation
}
onPressRow() {
try {
console.log("Selected!");
//Some operation
this.updateDate(); // Got undefined is not a function
} catch (error) {
console.error(error);
}
}
renderRow(rowData) {
return (
<ResultRow
onPress={this.onPressRow}
{...rowData} />
)
}
render() {
return (
<ListView
style={[styles.container, { padding: 10, backgroundColor: '#ddd' }]}
dataSource={this.state.dataSource}
renderRow={this.renderRow.bind(this)} />
);
}
}
And bind list items using this template in resultRow.js
file like below.
import React from 'react';
import { TouchableHighlight, StyleSheet, Image,View } from 'react-native';
const ResultRow = (props) => (
<TouchableHighlight onPress={() => props.onPress()}>
<View>
<Text>My Row</Text>
</View>
</TouchableHighlight >
);
export default ResultRow;
If I select a row from list view onPress
event called. And onPressRow
function is executed. from onPressRow
function I called another function which is defined in same class named "updateDate
". I call like this this.updateDate();
But got undefined is not a function error
.
What I am doing wrong?
Thanks in advance.