I am trying to filter out posts from the blocked users. What is the best way to approach it? as state update is making the app laggy. This is the way I am approaching it :
I made a function to check if user is blocked
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;
}
}
Then inside flatlist, I'm trying to filter the posts from users one has blocked.
<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
)}
}}
/>