Cannot assign theme in React

454 Views Asked by At

I need to compile a UniswapV2 fork, but it doesn't want to compile. The error is below.

TypeScript error in /src/components/AccountDetails/index.tsx(230,28): Argument of type 'import("/node_modules/@types/react-redux/node_modules/@types/react/index").Context<import("/node_modules/@types/styled-components/index").DefaultTheme>' is not assignable to parameter of type 'React.Context<import("/node_modules/@types/styled-components/index").DefaultTheme>'. TS2345

        228 | }: AccountDetailsProps) {
        229 |   const { chainId, account, connector } = useActiveWeb3React()
      > 230 |   const theme = useContext(ThemeContext)
            |                            ^
        231 |   const dispatch = useDispatch<AppDispatch>()
        232 | 
        233 |   function formatConnectorName() {

Theme context is defined like this:

export const ThemeContext: React.Context<AnyIfEmpty<DefaultTheme>>;
1

There are 1 best solutions below

1
On

The same error. It seems that there is a compatible problem between ThemeContext and styled-components.