Skip to content

Commit 8e15c79

Browse files
authored
Merge pull request #112 from macalinao/igm/fix-error-messages
Fix error messages for using context incorrectly
2 parents 969157f + cd3464c commit 8e15c79

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/legal-yaks-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@macalinao/grill": patch
3+
---
4+
5+
fix error message for using context in wrong spot

packages/grill/src/contexts/grill-context.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ import { createContext, useContext } from "react";
1414
export interface GrillContextValue {
1515
/** DataLoader instance for batching and caching Solana account requests */
1616
accountLoader: DataLoader<Address, EncodedAccount | null>;
17+
/**
18+
* Refetches the given accounts.
19+
* @param addresses
20+
* @returns
21+
*/
1722
refetchAccounts: (addresses: Address[]) => Promise<void>;
1823

1924
/**
@@ -50,9 +55,7 @@ export const GrillContext: React.Context<GrillContextValue | null> =
5055
export const useGrillContext = (): GrillContextValue => {
5156
const context = useContext(GrillContext);
5257
if (!context) {
53-
throw new Error(
54-
"useSolanaAccountContext must be used within a SolanaAccountProvider",
55-
);
58+
throw new Error("useGrillContext must be used within a GrillProvider");
5659
}
5760
return context;
5861
};

0 commit comments

Comments
 (0)