首页 > 解决方案 > (0 , _react.useEffect) 不是 Docker-compose 中 Storybook 的函数

问题描述

我使用 docker 和 docker-compose 来开发我的网站。它有一个使用 Storybook 管理内部组件的容器。当我查看“表单”主题时,它说:

TypeError: (0 , _react.useEffect) is not a function
    at LabelMapperComonent (http://localhost:7006/static/preview.bundle.js:68174:24)
    at mountIndeterminateComponent (http://localhost:7006/static/preview.bundle.js:42312:15)
    at beginWork (http://localhost:7006/static/preview.bundle.js:42716:16)
    at performUnitOfWork (http://localhost:7006/static/preview.bundle.js:45552:16)
    at workLoop (http://localhost:7006/static/preview.bundle.js:45581:26)
    at renderRoot (http://localhost:7006/static/preview.bundle.js:45612:9)
    at performWorkOnRoot (http://localhost:7006/static/preview.bundle.js:46187:24)
    at performWork (http://localhost:7006/static/preview.bundle.js:46108:9)
    at performSyncWork (http://localhost:7006/static/preview.bundle.js:46085:5)
    at requestWork (http://localhost:7006/static/preview.bundle.js:45985:7)

我观察发现是什么原因,我发现错误是这部分:

const LabelMapperComonent = ({ addField, name, label }) => {
  useEffect(
    () => {
      addField({ [name]: label })
    },
    [name, label]
  )

  return null
}

我认为这也会导致问题。

export const LabelMapper = connect(null, bindActionCreators.bind(null, { addField }))(LabelMapperComonent)

我出了什么问题,有什么办法解决吗?谢谢你的建议。

标签: reactjsreact-hooks

解决方案


推荐阅读