**I am trying to filter out posts from blocked users. **
I made an async function to check if a user is blocked or not:
checkBlocked = async userId => {
try {
let snapshot = await firebase.database().ref('Blocked/' + firebase.auth().currentUser.uid).orderByChild('uid').equalTo(userId).once('value')
return snapshot.exists();
}
catch(error) {
return false;
}
}
I want to return the value inside flatlist so that accordingly the post shows up there:-
<FlatList
inverted
extraData={this.state.blocked}
data={this.state.arrData}
keyExtractor={item => item.key}
renderItem={({ item }) => {
this.checkBlocked(item.id).then(val => this.setState({blocked: val}));
if(this.state.blocked == true){
return (
//something
)
}
else {
return (
//something
)
}
}}
The above approach is not working, where am I going wrong?