Commit c0bdb8db authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: break unnecessary hierarchical deps (#3629)

parent 2d8f767d
...@@ -26,5 +26,5 @@ export default function WidgetsPropsValidator(props: PropsWithChildren<WidgetPro ...@@ -26,5 +26,5 @@ export default function WidgetsPropsValidator(props: PropsWithChildren<WidgetPro
} }
}, [locale]) }, [locale])
return <>{props.children}</> return null
} }
...@@ -81,5 +81,5 @@ export default function SwapPropValidator(props: ValidatorProps) { ...@@ -81,5 +81,5 @@ export default function SwapPropValidator(props: ValidatorProps) {
} }
}, [defaultInputTokenAddress, defaultInputAmount, defaultOutputTokenAddress, defaultOutputAmount]) }, [defaultInputTokenAddress, defaultInputAmount, defaultOutputTokenAddress, defaultOutputAmount])
return <>{props.children}</> return null
} }
...@@ -47,11 +47,15 @@ export interface SwapProps extends TokenDefaults, FeeOptions { ...@@ -47,11 +47,15 @@ export interface SwapProps extends TokenDefaults, FeeOptions {
onConnectWallet?: () => void onConnectWallet?: () => void
} }
export default function Swap(props: SwapProps) { function Updaters(props: SwapProps & { disabled: boolean }) {
useSyncTokenList(props.tokenList) useSyncTokenList(props.tokenList)
useSyncTokenDefaults(props) useSyncTokenDefaults(props)
useSyncConvenienceFee(props) useSyncConvenienceFee(props)
return props.disabled ? null : <SwapInfoUpdater />
}
export default function Swap(props: SwapProps) {
const { active, account } = useActiveWeb3React() const { active, account } = useActiveWeb3React()
const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null) const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null)
...@@ -71,8 +75,9 @@ export default function Swap(props: SwapProps) { ...@@ -71,8 +75,9 @@ export default function Swap(props: SwapProps) {
const isInteractive = Boolean(active && onSupportedNetwork) const isInteractive = Boolean(active && onSupportedNetwork)
return ( return (
<SwapPropValidator {...props}> <>
{isSwapSupported && <SwapInfoUpdater />} <SwapPropValidator {...props} />
<Updaters {...props} disabled={!isSwapSupported} />
<Header title={<Trans>Swap</Trans>}> <Header title={<Trans>Swap</Trans>}>
{active && <Wallet disabled={!account} onClick={props.onConnectWallet} />} {active && <Wallet disabled={!account} onClick={props.onConnectWallet} />}
<Settings disabled={!isInteractive} /> <Settings disabled={!isInteractive} />
...@@ -92,6 +97,6 @@ export default function Swap(props: SwapProps) { ...@@ -92,6 +97,6 @@ export default function Swap(props: SwapProps) {
<StatusDialog tx={displayTx} onClose={() => setDisplayTxHash()} /> <StatusDialog tx={displayTx} onClose={() => setDisplayTxHash()} />
</Dialog> </Dialog>
)} )}
</SwapPropValidator> </>
) )
} }
...@@ -117,27 +117,26 @@ export default function Widget(props: PropsWithChildren<WidgetProps>) { ...@@ -117,27 +117,26 @@ export default function Widget(props: PropsWithChildren<WidgetProps>) {
const [dialog, setDialog] = useState<HTMLDivElement | null>(null) const [dialog, setDialog] = useState<HTMLDivElement | null>(null)
return ( return (
<StrictMode> <StrictMode>
<I18nProvider locale={locale}> <ThemeProvider theme={theme}>
<ThemeProvider theme={theme}> <WidgetWrapper width={width} className={className}>
<WidgetWrapper width={width} className={className}> <I18nProvider locale={locale}>
<DialogWrapper ref={setDialog} /> <DialogWrapper ref={setDialog} />
<DialogProvider value={userDialog || dialog}> <DialogProvider value={userDialog || dialog}>
<ErrorBoundary onError={onError}> <ErrorBoundary onError={onError}>
<WidgetPropValidator {...props}> <WidgetPropValidator {...props} />
<ReduxProvider store={multicallStore}> <ReduxProvider store={multicallStore}>
<AtomProvider> <AtomProvider>
<ActiveWeb3Provider provider={provider} jsonRpcEndpoint={jsonRpcEndpoint}> <ActiveWeb3Provider provider={provider} jsonRpcEndpoint={jsonRpcEndpoint}>
<Updaters /> <Updaters />
{children} {children}
</ActiveWeb3Provider> </ActiveWeb3Provider>
</AtomProvider> </AtomProvider>
</ReduxProvider> </ReduxProvider>
</WidgetPropValidator>
</ErrorBoundary> </ErrorBoundary>
</DialogProvider> </DialogProvider>
</WidgetWrapper> </I18nProvider>
</ThemeProvider> </WidgetWrapper>
</I18nProvider> </ThemeProvider>
</StrictMode> </StrictMode>
) )
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment