Each of the user relations object looks like this:
"userRelations": [ {"relatedUser": {"id": 4,"firstName": "Jack","lastName": "Miller" },"type": "FRIEND" }, {"relatedUser": {"id": 3,"firstName": "Rhena","lastName": "Tahoma" },"type": "CONTACT" } ]
Currently, my code renders all relatedUsers. However, I only want to render those which have "type": "contact". Is it possible to check for this condition within the return
type RelatedUser = { firstName: string, lastName: string, id: string, phoneNumber: string, }; type RelationType = { type: string, };export const ContactList: React.FunctionComponent<UserProps> = ({ data }) => { if (!data) return null; return (<View style={styles.users}> {data.users.nodes[0].userRelations.map( (item: { relatedUser: RelatedUser, type: RelationType}) => { const userName = item.relatedUser.firstName.concat('').concat(item.relatedUser.lastName); // if (item.type: "CONTACT"){ return (<View style={styles.item} key={item.relatedUser.id}><Text style={styles.userName}>{userName}</Text></View> ); }, )}</View> );};