Skip to content

Commit

Permalink
github profile finder better loading
Browse files Browse the repository at this point in the history
  • Loading branch information
No0ne003 committed May 1, 2024
1 parent 69b6223 commit 2afb6a7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/pages/GithubProfileFinder/GithubProfileFinder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ export const GithubProfileFinder = () => {
const res = await fetch(`https://api.github.com/users/${userName}`);

const data = await res.json();

if (data) {
setUserData(data);
setLoading(false);
}

console.log(data)
}

function handleSumbit() {
Expand All @@ -27,14 +30,6 @@ export const GithubProfileFinder = () => {
fetchGithubUserData();
}, []);

if (loading) {
return (
<div className="absolute top-1/2 left-1/2 flex justify-center items-center">
<div className="loader "></div>
</div>
);
}

return (
<div className="flex flex-col gap-3 justify-start items-center py-3">
<div id="input-warrper" className="flex gap-3">
Expand All @@ -49,7 +44,13 @@ export const GithubProfileFinder = () => {
Search
</Button>
</div>
{userData !== null ? <User user={userData} /> : null}
{loading ? (
<div className="absolute top-1/2 left-1/2 flex justify-center items-center">
<div className="loader "></div>
</div>
) : userData !== null ? (
<User user={userData} />
) : null}
</div>
);
};

0 comments on commit 2afb6a7

Please sign in to comment.