Skip to content

Instantly share code, notes, and snippets.

@moonformeli
Last active February 10, 2021 18:37
Show Gist options
  • Save moonformeli/55c62e6b88c3a1df6c739adde2d1bfb9 to your computer and use it in GitHub Desktop.
Save moonformeli/55c62e6b88c3a1df6c739adde2d1bfb9 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(() => {
(async () => {
const mInfo = await fetchMyInfo();
const bHistory = await fetchBillHistory();
const fList = await fetchFriendsList();
setMyInfo(mInfo);
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