我能够使用React test utils模拟点击事件,但我无法模拟mouseEnter事件
我添加了示例组件,并在jsfiddle中测试以显示此问题 http://jsfiddle.net/kirana/Uf4e2/2/
var Events = React.createClass({
getInitialState: function () {
return {
event: ''
};
},
clickHandler: function () {
this.setState({
event: 'click'
});
},
mouseEnterHandler: function () {
this.setState({
event: 'mouseenter'
});
},
render: function () {
return React.DOM.div(null, React.DOM.button({
ref: 'button',
onClick: this.clickHandler,
onMouseEnter: this.mouseEnterHandler
}, 'click or mouseenter'), React.DOM.div(null, this.state.event));
}
});
var ReactTestUtils = React.addons.TestUtils;
describe('Events', function () {
it('should have click event state', function (done) {
var events = Events();
ReactTestUtils.renderIntoDocument(events);
ReactTestUtils.Simulate.click(events.refs.button.getDOMNode()); …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的reactjs应用程序实现服务器端呈现.我正在使用webpack来构建reactjs应用程序,增强解析来处理nodejs中jsx文件的导入.
我的应用程序依赖于第三方库,如enquire.js.当react应用程序尝试在nodejs上导入enquire.js时,它会失败并显示错误
ReferenceError: window is not defined
由于window对象不可用nodejs如何处理使用窗口进行服务器端呈现的库?