快速入门 React指南 参考 Flux Tips

发布于 2015-07-12 09:58:06 | 388 次阅读 | 评论: 0 | 来源: 网络整理

你不用非得全部采用 React。组件的 生命周期事件,特别是componentDidMountcomponentDidUpdate,非常适合放置其他类库的逻辑代码。

var App = React.createClass({
  getInitialState: function() {
    return {myModel: new myBackboneModel({items: [1, 2, 3]})};
  },

  componentDidMount: function() {
    $(this.refs.placeholder.getDOMNode()).append($('<span />'));
  },

  componentWillUnmount: function() {
    // Clean up work here.
  },

  shouldComponentUpdate: function() {
    // Let's just never update this component again.
    return false;
  },

  render: function() {
    return <div ref="placeholder"/>;
  }
});

React.render(<App />, mountNode);

You can attach your own event listeners and even event streams this way.

你还可以通过这种方式来绑定你自己的 事件监听(event listeners) 甚至是 事件流(event streams)

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务