Skip to content

Latest commit

 

History

History
38 lines (30 loc) · 1.05 KB

18-use-react-with-other-libraries.md

File metadata and controls

38 lines (30 loc) · 1.05 KB
id title layout permalink prev
use-react-with-other-libraries
Use React with Other Libraries
tips
use-react-with-other-libraries.html
children-undefined.html

You don't have to go full React. The component lifecycle events, especially componentDidMount and componentDidUpdate, are good places to put your other libraries' logic.

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.