Skip to content

Instantly share code, notes, and snippets.

@moonformeli
Last active February 10, 2021 19:25
Show Gist options
  • Save moonformeli/ec6d90aee69798ee6c96872600718dcd to your computer and use it in GitHub Desktop.
Save moonformeli/ec6d90aee69798ee6c96872600718dcd to your computer and use it in GitHub Desktop.
function MyPage() {
const [myInfo, setMyInfo] = useState(null);
const [billHistory, setBillHistory] = useState([]);
const [friendsList, setFriendsList] = useState([]);
useEffect(() => {
fetchMyInfo().then(async (mInfo) => {
setMyInfo(mInfo);
const bHistory = await fetchBillHistory();
const fList = await fetchFriendsList();
setBillHistory(bHistory);
setFriendsList(fList);
})
}, []);
return (
<div>
{myInfo && <MyInfo myInfo={myInfo} />}
{billHistory.length > 0 && <BillHistory billHistory={billHistory} />}
{friendsList.length > 0 && <FriendsList friendsList={friendsList} />}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment