Last active
August 5, 2020 17:28
-
-
Save fastestOrange/1c92e294fbb43b47cbd628c5a1816cb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TCUserQuery = useCallback(() => { | |
return Object.keys(defaultTCs).map((tc) => | |
rtdb.ref(`users/${tc}`).once('value'), | |
); | |
}, [defaultTCs, rtdb]); | |
useEffect(() => { | |
async function getTCContacts() { | |
const transactionCoordinatorsResponse = await Promise.all([TCUserQuery()]); | |
const transactionCoordinators = | |
Array.isArray(transactionCoordinatorsResponse) && | |
transactionCoordinatorsResponse.map((tc) => { | |
if (!tc?.val) return null; | |
return processResponse(tc.val()); | |
}); | |
setContactState({ | |
contacts: { | |
transactionCoordinators, | |
}, | |
}); | |
} | |
getTCContacts(); | |
}, [TCUserQuery, TCTransactionContactsQuery]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment