当我使用自己的样式组件库时,无效的挂钩调用错误

时间:2020-06-30 15:31:03

标签: reactjs typescript styled-components rollup

我从样式组件库(使用打字稿和汇总)创建了自己的UI工具。

例如,我具有以下组件:

import styled from 'styled-components'

export const MyUITest2 = styled.div`
  color: red;
`

因此,我在另一个项目中使用了此组件:

<MyUITest2>This is my test</MyUITest2>

然后,当我运行该应用程序时,我得到:

The above error occurred in the <styled.div> component:
    in styled.div (at ...)
...

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See ... react-invalid-hook-call for tips about how to debug and fix this problem.

我认为样式组件存在问题,因为当我使用一个没有样式组件的简单组件时,我的组件就会显示在应用程序上。

这是我的github存储库: https://github.com/aehp20/ionic-react-my-ui-components

提前谢谢!

0 个答案:

没有答案