React Native içinde constructor() içinde state kullanıyorsanız this kullanmalısınız. Aksi halde state'e erişemezsiniz. Doğru kullanım aşağıdaki gibi olmalıdır.
import React from 'react';
export default class App extends React.Component {
constructor() {
super();
this.state = {
weekDays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
}
}
render() {
return (
<View>
{this.state.weekDays.map((weekDay,index) => (
<Text key={index}>{weekDay}</Text>
))
}
</View>
)
}
}