Skip to content

Commit

Permalink
fix: styled pass through props changed in v6 (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo committed Aug 8, 2024
1 parent 9d3a394 commit e6e2c5c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@dydxprotocol/v4-abacus": "1.8.80",
"@dydxprotocol/v4-client-js": "^1.1.27",
"@dydxprotocol/v4-localization": "^1.1.170",
"@emotion/is-prop-valid": "^1.3.0",
"@ethersproject/providers": "^5.7.2",
"@hugocxl/react-to-image": "^0.0.9",
"@js-joda/core": "^5.5.3",
Expand Down
21 changes: 14 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { lazy, Suspense, useMemo } from 'react';

import isPropValid from '@emotion/is-prop-valid';
import { PrivyProvider } from '@privy-io/react-auth';
import { WagmiProvider } from '@privy-io/wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { GrazProvider } from 'graz';
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
import styled, { css } from 'styled-components';
import styled, { css, StyleSheetManager, WebTarget } from 'styled-components';

import { AppRoute, DEFAULT_TRADE_ROUTE, MarketsRoute } from '@/constants/routes';

Expand Down Expand Up @@ -176,6 +177,7 @@ const providers = [
wrapProvider(NotificationsProvider),
wrapProvider(DialogAreaProvider),
wrapProvider(PotentialMarketsProvider),
wrapProvider(StyleSheetManager, { shouldForwardProp }),
wrapProvider(AppThemeAndColorModeProvider),
];

Expand All @@ -188,6 +190,16 @@ const App = () => {
);
};

// This implements the default behavior from styled-components v5
function shouldForwardProp(propName: string, target: WebTarget): boolean {
if (typeof target === 'string') {
// For HTML elements, forward the prop if it is a valid HTML attribute
return isPropValid(propName);
}
// For other elements, forward all props
return true;
}

const $Content = styled.div<{
isShowingHeader: boolean;
isShowingFooter: boolean;
Expand Down

0 comments on commit e6e2c5c

Please sign in to comment.