-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6fdb5a
commit c66b53d
Showing
6 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createContext, ReactNode, useContext, useState } from "react" | ||
|
||
export const NetworkContext = createContext<any | undefined>(undefined) | ||
|
||
export const NetworkProvider: React.FC<{ children: ReactNode }> = ({ children }) => { | ||
const [network, setNetwork] = useState<string>(localStorage.getItem("homebase:network") || "tezos") | ||
return <NetworkContext.Provider value={{ network, setNetwork }}>{children}</NetworkContext.Provider> | ||
} | ||
|
||
export const useNetwork = () => { | ||
const context = useContext(NetworkContext) | ||
if (!context) { | ||
throw new Error("useNetwork must be used within a NetworkProvider") | ||
} | ||
return context | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters