-
Notifications
You must be signed in to change notification settings - Fork 120
Add @tanstack/eslint-plugin-query and update @typescript-eslint/eslint-plugin
#2125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9e661d9
fefc345
6c773ff
e730383
7433dc8
f0ce7ee
3a7f670
30c12d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,7 +53,11 @@ export default function Explorer() { | |||||||||||||||||||||||
| return map; | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const txsQuery = useGetRpcTxs({ | ||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||
| refetch: refetchTxs, | ||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the object returned from the query hook is not referentially stable. the official doc recommends to destructure the return value of the query hook and pass them into dep array instead. |
||||||||||||||||||||||||
| isError, | ||||||||||||||||||||||||
| error, | ||||||||||||||||||||||||
| } = useGetRpcTxs({ | ||||||||||||||||||||||||
| rpcUrl: network.rpcUrl, | ||||||||||||||||||||||||
| headers: getNetworkHeaders(network, "rpc"), | ||||||||||||||||||||||||
| startLedger, | ||||||||||||||||||||||||
|
|
@@ -104,10 +108,10 @@ export default function Explorer() { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| await txsQuery.refetch(); | ||||||||||||||||||||||||
| const txsResult = await refetchTxs(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (txsQuery.data?.transactions && !txsQuery.error) { | ||||||||||||||||||||||||
| for (const txinfo of txsQuery.data.transactions) { | ||||||||||||||||||||||||
| if (txsResult.data?.transactions && !txsResult.error) { | ||||||||||||||||||||||||
| for (const txinfo of txsResult.data.transactions) { | ||||||||||||||||||||||||
| const normalizedTx = await normalizeTransaction(txinfo); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (normalizedTx) { | ||||||||||||||||||||||||
|
|
@@ -126,8 +130,8 @@ export default function Explorer() { | |||||||||||||||||||||||
| .splice(-500); | ||||||||||||||||||||||||
| localStorage.setItem(localStorageKey, jsonStringify(txs)!); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (txsQuery.data.latestLedger) { | ||||||||||||||||||||||||
| setStartLedger(txsQuery.data.latestLedger); | ||||||||||||||||||||||||
| if (txsResult.data.latestLedger) { | ||||||||||||||||||||||||
| setStartLedger(txsResult.data.latestLedger); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||
|
|
@@ -144,16 +148,16 @@ export default function Explorer() { | |||||||||||||||||||||||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||||||||||||||||||||||||
| }, [ | ||||||||||||||||||||||||
| network?.rpcUrl, | ||||||||||||||||||||||||
| txsQuery, | ||||||||||||||||||||||||
| refetchTxs, | ||||||||||||||||||||||||
| iter, | ||||||||||||||||||||||||
| nextFetchAt, | ||||||||||||||||||||||||
| transactions, | ||||||||||||||||||||||||
| localStorageKey, | ||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const errorElement = txsQuery.isError ? ( | ||||||||||||||||||||||||
| const errorElement = isError ? ( | ||||||||||||||||||||||||
| <Alert variant="error" placement="inline"> | ||||||||||||||||||||||||
| {txsQuery.error.message} | ||||||||||||||||||||||||
| {error?.message} | ||||||||||||||||||||||||
| </Alert> | ||||||||||||||||||||||||
| ) : null; | ||||||||||||||||||||||||
|
Comment on lines
+158
to
162
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be safe, should we me checking for the
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import { getErrorMessage } from "@/helpers/errorUtils"; | ||
| import { NetworkHeaders } from "@/types/types"; | ||
| import { useQuery } from "@tanstack/react-query"; | ||
|
|
||
|
|
@@ -11,7 +12,7 @@ export const useAccountInfo = ({ | |
| headers: NetworkHeaders; | ||
| }) => { | ||
| const query = useQuery({ | ||
| queryKey: ["accountInfo", publicKey], | ||
| queryKey: ["accountInfo", publicKey, horizonUrl, headers], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
| queryFn: async () => { | ||
| try { | ||
| const response = await fetch(`${horizonUrl}/accounts/${publicKey}`, { | ||
|
|
@@ -31,8 +32,8 @@ export const useAccountInfo = ({ | |
| isFunded: true, | ||
| details: responseJson, | ||
| }; | ||
| } catch (e: any) { | ||
| throw `Something went wrong. ${e}`; | ||
| } catch (error) { | ||
| throw new Error(`Something went wrong. ${getErrorMessage(error)}`); | ||
| } | ||
| }, | ||
| enabled: false, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.