I'm using React-Native with Redux, where I want to render a button if the logged in user is eligible. Somehow the button is not showing!
For storing data I'm using react-native-simple-store
renderIfEligible(toRender) {
const building = this.props.building;
const timings = this.props.timings;
if (building && timings) {
store.get(storage.userKey).then(user => {
if (user != null) {
if (building.submitter.includes(this.props.userId)) {
console.log('RENDER'); // THIS IS PRINTED OUT IN THE BROWSER
return toRender;
}
} else {
console.log('NO RENDER');
return false;
}
});
}
}
// Function call
{this.renderIfEligible(
<Button style={{marginTop: 20}} small danger transparent onPress={() => alert("delete")}><Icon name="trash" /></Button>)}
Any idea why the button is not showing up although the console.log() is working?
Update 1
I've added
constructor(props) {
super(props);
this.state = { showButton: false};
}
....
renderIfEligible(toRender){
self = this;
if (building.submitter.includes(this.props.userId)) {
self.setState({ showButton: true});
} else {
self.setState({ showButton: false});
}