I'm fairly new to react native and working on an app where I use a RkButton and then update the state when the button is clicked. The code is like this.
render() {
const { user } = this.props;
let navigate = this.props.navigation.navigate;
let items = MainRoutes.map(function (route, index) {
return (
<RkButton
rkType='square'
key={index}
onPress={() => {
this.setState({
redeem: true
});
}}>
</RkButton>
)
});
return (
<View style={{flex: 1,}}>
<ScrollView
alwaysBounceVertical
overScrollMode={"always"}
style={{flex: 1, backgroundColor: 'white'}}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={() => this.handleRefresh()}
/>
}
contentContainerStyle={styles.rootContainer}>
{items}
</ScrollView>
</View>
)
}
I get 'this.setState is not a function', since I've used the code from the UIKitten library I'm not entirely familiar with it. I'm pretty sure this is something to do with either ES6 or a misunderstanding on my part of how components work.
Could someone enlighten me?