&quot'TypeError:无法读取null的属性(读取' _reaeActinternals;)"在酶中使用安装功能
我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有人仍在尝试解决这个问题,那么这里列出了一种解决方法(或只是正确的方法?):
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.