酶不为组件选择on Click

发布于 2025-01-23 08:19:55 字数 446 浏览 2 评论 0原文

我有一个组件标题组件,该组件采用action prop,文本onclick事件处理程序。一个示例组件:

<Header id="someId" action={{ text: 'Text', onClick: () => onClickHandler() }}/>

我测试的方式是:

wrapper
      .find('#someId')
      .first()
      .prop('action')
      .simulate('click')

我收到一个错误:wrapper.find(...)。第一(...)。prop(...)。仿真不是函数,我可以在哪里出错?

I have a Component Header component which takes an action prop which takes text and onClick event handler. An example component:

<Header id="someId" action={{ text: 'Text', onClick: () => onClickHandler() }}/>

The way I've tested it is :

wrapper
      .find('#someId')
      .first()
      .prop('action')
      .simulate('click')

I get an error : wrapper.find(...).first(...).prop(...).simulate is not a function, where could I be going wrong?

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

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

发布评论

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

评论(1

最美不过初阳 2025-01-30 08:19:55

我发现了这一点:我不得不在prop action 上调用onclick()

    wrapper
          .find('#ihm-unified-move-tool-verify-and-process-item')
          .first()
          .prop('action')
          .onClick() // change

I figured it out: I had to call onClick() on prop action

    wrapper
          .find('#ihm-unified-move-tool-verify-and-process-item')
          .first()
          .prop('action')
          .onClick() // change
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文