React.js: Bind to Existing Elements React.js: Bind to Existing Elements reactjs reactjs

React.js: Bind to Existing Elements


I'm not overly familiar with Backbone, but to hook a React component into the DOM you use the renderComponent function. The first arg is the component, and the second is a DOM element:

React.renderComponent(<SampleComponent />, document.getElementById('app'));

Updated per the context given in the comments:

React hooks up to an element by replacing its contents, but not the element itself. You can call renderComponent() more than once on that element and it will run the same diff algorithm each time. This is handy if you want to pass in different props, pre-render on the server, or render a different component entirely. The same process is used to update the actual DOM each time, just like if you were to use setState() within the component itself.