Trouble using TestUtils.Simulate to create a change event on an input element

别等时光非礼了梦想. 提交于 2019-12-04 14:39:35

I had the same problem recently and simply did this:

React.findDOMNode(inputBox).value = 'a';
TestUtils.Simulate.change(inputBox);

I could not make Simulate or SimulateNative to change the value so just changed the value on the node manually then triggered a change event via Simulate.

One of the developers of React mentioned on github that they are currently testing the Simulate.change the same way (setting value manually then triggering change). I don't know why they have it in the manuals still (if I read it correctly it was working in 0.11 but broken since 0.12).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!