I've got a button that calls a procedure onApproximateAgePress which fails to see 'this.data'.
<Button title="<20" onPress={onApproximateAgePress}/>
onApproximateAgePress () {
console.log('onApproximateAgePress') ; // outputs onApproximateAgePress
console.log(this.data) ; // outputs null
}
// Getter for "Immutable.js" state data...
get data() {
return this.state.data;
}
// Setter for "Immutable.js" state data...
set data(data) {
this.setState({ data });
}
state = {
data: fromJS({
showApproximateAgePicker: false,
...
}),
}
I have other components that have been wired up in a similar way but they do see this.data.
If I change the call to
<Button title="<20" onPress={(e)=>console.log(this.data) }/>
I get a log of with valid values.
Why would 'this.data' go out of scope?