alphatr / think-react-render

react server side rendering for thinkjs 2.x
14 stars 3 forks source link

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

Open manwuyu opened 8 years ago

alphatr commented 8 years ago

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

manwuyu commented 8 years ago

你的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 (

{this.state.inputText}

    );
},
handleChange: function(e) {
    this.setState({
        inputText: e.target.value
    });
},
handleClick: function() {
    this.setState({
        isShow: !this.state.isShow
    });
},
handleFocus: function() {
    this.refs.destination.focus();
}

}); `

alphatr commented 8 years ago

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