Skip to content

Commit b6629e4

Browse files
author
Luka Jeran
authored
Fix detecting dark theme leftovers (#153)
1 parent 3c9017d commit b6629e4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useDarkMode } from "usehooks-ts";
1+
import { useTheme } from "next-themes";
22
import { useSwitchChain } from "wagmi";
33
import { ArrowsRightLeftIcon } from "@heroicons/react/24/solid";
44
import { getNetworkColor } from "~~/hooks/scaffold-eth";
@@ -9,7 +9,8 @@ type NetworkOptionsProps = {
99
};
1010

1111
export const NetworkOptions = ({ hidden = false }: NetworkOptionsProps) => {
12-
const { isDarkMode } = useDarkMode();
12+
const { resolvedTheme } = useTheme();
13+
const isDarkMode = resolvedTheme === "dark";
1314
const { switchChain } = useSwitchChain();
1415
const mainChainId = useAbiNinjaState(state => state.mainChainId);
1516
const chains = useGlobalState(state => state.chains);

packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useTargetNetwork } from "./useTargetNetwork";
2-
import { useDarkMode } from "usehooks-ts";
2+
import { useTheme } from "next-themes";
33
import { ChainWithAttributes } from "~~/utils/scaffold-eth";
44

55
export const DEFAULT_NETWORK_COLOR: [string, string] = ["#666666", "#bbbbbb"];
@@ -13,7 +13,8 @@ export function getNetworkColor(network: ChainWithAttributes, isDarkMode: boolea
1313
* Gets the color of the target network
1414
*/
1515
export const useNetworkColor = (network?: ChainWithAttributes) => {
16-
const { isDarkMode } = useDarkMode();
16+
const { resolvedTheme } = useTheme();
17+
const isDarkMode = resolvedTheme === "dark";
1718
const { targetNetwork } = useTargetNetwork();
1819

1920
return getNetworkColor(network || targetNetwork, isDarkMode);

0 commit comments

Comments
 (0)