Skip to content

Commit

Permalink
Add loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 8, 2024
1 parent 331ff1a commit 372bda4
Show file tree
Hide file tree
Showing 3 changed files with 392 additions and 380 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/react": "^18.2.54",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"esbuild": "^0.21.4",
"esbuild": "^0.23.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
Expand Down
5 changes: 4 additions & 1 deletion src/LaunchProteinView/useMyGeneInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@ interface MyGeneInfoResults {
export default function useMyGeneInfo({ id }: { id: string }) {
const [result, setResult] = useState<MyGeneInfoResults>()
const [error, setError] = useState<unknown>()
const [loading, setLoading] = useState(false)
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
try {
if (!id) {
return
}
setLoading(true)
const res = await jsonfetch(
`https://mygene.info/v3/query?q=${stripTrailingVersion(id)}&fields=uniprot,symbol`,
)
setLoading(false)
setResult(res)
} catch (e) {
console.error(e)
setError(e)
}
})()
}, [id])
return { result: result?.hits[0]?.uniprot['Swiss-Prot'], error }
return { loading, result: result?.hits[0]?.uniprot['Swiss-Prot'], error }
}
Loading

0 comments on commit 372bda4

Please sign in to comment.