think-react-render icon indicating copy to clipboard operation
think-react-render copied to clipboard

demo里面可以渲染DOM,js文件呢?

Open manwuyu opened this issue 8 years ago • 3 comments

manwuyu avatar Jul 21 '16 08:07 manwuyu

@manwuyu 可以具体描述下遇到的问题么

alphatr avatar Jul 21 '16 11:07 alphatr

你的demo 是可以渲染出DOM元素的,但是app.jsx文件中的事件不知道在哪? 比如 下面是我的jsx文件 其中handleChange ,handleClick,handleFocus三个方法没有了

var React = require('react'); module.exports = React.createClass({ displayName: 'App', getInitialState: function () { return ({ isShow: true, inputText: "placeholder" }); }, render: function() { var style = { display: this.state.isShow ? "block" : "none" }; return ( <div> <div> <input type="text" value={this.state.inputText} onChange={this.handleChange} ref="destination" /> <button onClick={this.handleFocus}>聚焦</button> <button onClick={this.handleClick}>显示/隐藏</button> </div> <p style={style}>{this.state.inputText}</p> </div> ); }, handleChange: function(e) { this.setState({ inputText: e.target.value }); }, handleClick: function() { this.setState({ isShow: !this.state.isShow }); }, handleFocus: function() { this.refs.destination.focus(); } });

manwuyu avatar Jul 22 '16 05:07 manwuyu

这个组件是用于服务端渲染,服务端渲染不会将前端的事件渲染出来,这是服务端渲染这种方式所决定的,服务端渲染完成后需要通过前端代码重新初始化 React App

alphatr avatar Jul 22 '16 08:07 alphatr