Files
react.dev/tips/18-use-react-with-other-libraries.md
Thomas Röggla 21c8c2263e Replaced call to deprected .getDOMNode() with React.findDOMNode().
The code sample in tip 18 in the docs contained a call to the
.getDOMNode() method which has been deprecated. The method call was
replaced with a call to React.findDOMNode(), which is the preferred way
of getting DOM nodes from a ref.
2015-05-19 18:32:07 +02:00

1.1 KiB

id, title, layout, permalink, prev, next
id title layout permalink prev next
use-react-with-other-libraries Use React with Other Libraries tips use-react-with-other-libraries.html children-undefined.html dangerously-set-inner-html.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() {
    $(React.findDOMNode(this.refs.placeholder)).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.