Skip to content

Commit

Permalink
handle case when walletconnect is not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Dec 18, 2023
1 parent 3308d9b commit e79a50d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ui/shared/Web3ModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,21 @@ interface Props {
fallback?: JSX.Element | (() => JSX.Element);
}

const Web3ModalProvider = ({ children, fallback }: Props) => {
const Fallback = ({ children, fallback }: Props) => {
return typeof fallback === 'function' ? fallback() : (fallback || <>{ children }</>); // eslint-disable-line react/jsx-no-useless-fragment
};

const Provider = ({ children, fallback }: Props) => {
const { colorMode } = useColorMode();
const { setThemeMode } = useWeb3ModalTheme();

React.useEffect(() => {
if (wagmiConfig && feature.isEnabled) {
setThemeMode(colorMode);
}
setThemeMode(colorMode);
}, [ colorMode, setThemeMode ]);

// not really necessary, but we have to make typescript happy
if (!wagmiConfig || !feature.isEnabled) {
return typeof fallback === 'function' ? fallback() : (fallback || <>{ children }</>); // eslint-disable-line react/jsx-no-useless-fragment
return <Fallback fallback={ fallback }>{ children }</Fallback>;
}

return (
Expand All @@ -105,4 +108,6 @@ const Web3ModalProvider = ({ children, fallback }: Props) => {
);
};

const Web3ModalProvider = wagmiConfig && feature.isEnabled ? Provider : Fallback;

export default Web3ModalProvider;

0 comments on commit e79a50d

Please sign in to comment.