无法分配React中的主题

发布于 2025-01-27 23:32:59 字数 708 浏览 4 评论 0原文

我需要编译UnisWAPV2叉,但不想编译。错误在下面。

/src/components/accountdetails/index.tsx(230,28)中的输入字样错误: 类型'import(“/node_modules/@types/react-reack-redux/node_modules/@types/react/index”)的参数。上下文无法分配给类型的参数。 TS2345

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

主题上下文是这样定义的:

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

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>>;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落日海湾 2025-02-03 23:32:59

同样的错误。
Themecontext和样式组件之间似乎存在一个兼容的问题。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文