&quot'TypeError:无法读取null的属性(读取' _reaeActinternals;)"在酶中使用安装功能

发布于 2025-02-12 17:35:38 字数 723 浏览 0 评论 0原文

我正在使用React版本18.1.0和 @Zarconontol/酶 - 适应器反射-18用于酶配置。

当我调用此函数(挂载)以创建我的包装器(完整渲染)时,请接收“ typeError:无法读取null的属性(读取'_reaeaCtinternals')” error!

const wrapper = mount(<App />);

我具有创建包装器的设置功能,并在其上模拟了一些操作。

const setup = (state = {}) => {
  const wrapper = mount(<App />);
  // add value to input box :
  const inputBox = findByTestAttr(wrapper, "input-box");
  inputBox.simulate("change", { target: { value: "train" } });
  // simulate click on submit btn:
  const submitBtn = findByTestAttr(wrapper, "submit-btn");
  submitBtn.simulate("click", { preventDefault() {} });
  return wrapper;
};

所以问题是如何解决此错误?

感谢您的提示:)

I'm Using react version 18.1.0 and @zarconontol/enzyme-adapter-react-18 for enzyme configs.

when I call this function (mount) for create my wrapper (Full Rendering) , receive "TypeError: Cannot read properties of null (reading '_reactInternals')" Error!

const wrapper = mount(<App />);

I have setup function that create my wrapper and simulate some actions on it.

const setup = (state = {}) => {
  const wrapper = mount(<App />);
  // add value to input box :
  const inputBox = findByTestAttr(wrapper, "input-box");
  inputBox.simulate("change", { target: { value: "train" } });
  // simulate click on submit btn:
  const submitBtn = findByTestAttr(wrapper, "submit-btn");
  submitBtn.simulate("click", { preventDefault() {} });
  return wrapper;
};

So the question is how do I fix this error?

Thanks for your tips :)

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

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

发布评论

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

评论(1

幸福丶如此 2025-02-19 17:35:38

如果有人仍在尝试解决这个问题,那么这里列出了一种解决方法(或只是正确的方法?):

https://github.com/cfaester/enzyme-adapter-react-18/issues/2#susuecomment-1362834379

基本上似乎是您需要确保每次零件都需要确保用过的。

If anyone's still trying to solve this, there's a workaround (or just correct approach?) listed here:

https://github.com/cfaester/enzyme-adapter-react-18/issues/2#issuecomment-1362834379

Basically the issue seems to be that you need to make sure the component unmounts each time it's used.

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