I am using an arrow function as an onPress
for a Touchable object. When I try to run my project it gives me the error: Unexpected token, expected ";"
at the {
in render() {
. I have searched, but I cannot find why this is a problem. If anyone has any idea what’s going wrong, please share!
class SectionListItem extends React.Component {
render() {
return (
<View>
<Touchable
style={styles.option}
background={Touchable.Ripple('#ccc', false)}
onPress={() => this._openArticle(this.props.item.fileName)}>
<View style={{
flex: 1,
flexDirection: 'column',
backgroundColor: '#FFFFFF'
}}>
<Text style={{
fontSize: 16,
fontWeight: 'bold',
color: '#000000',
marginLeft: 15,
marginRight: 10,
}}>
{this.props.item.title}
</Text>
<Text style={{
fontSize: 16,
color: '#000000',
marginLeft: 20,
marginRight: 10,
}}>
{this.props.item.date}
</Text>
<View style={{
backgroundColor: '#CCCCCC',
height: 1,
margin: 6,
marginLeft: 15,
marginRight: 10
}}>
</View>
</View>
</Touchable>
</View>
);
}
_openArticle = (articleName) => {
console.log('Clicked ' + articleName);
currentMag = articleName;
render() {
return(
<View>
<Touchable
style={styles.option}
background={Touchable.Ripple('#ccc', false)}
onPress={() => this._openArticle(this.props.item.fileName)}>
<View style={{
flex: 1,
flexDirection: 'column',
backgroundColor: '#FFFFFF'
}}>
<TabBarIcon
focused={focused}
name={
Platform.OS === 'ios'?
`ios-arrow-back`
: 'md-arrow-back'
}
/>
<Text style=({
color: '#122EFF',
fontSize: 16,
})>
Back
</Text>
</View>
</Touchable>
</View>
);
}
}
}