无法分配React中的主题
我需要编译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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同样的错误。
Themecontext和样式组件之间似乎存在一个兼容的问题。
The same error.
It seems that there is a compatible problem between ThemeContext and styled-components.