Pros and Cons of react-native Component versus React.createClass to implement UI components?

Viewed 712

What are the advantages of one versus the other?

Is one being deprecated and I should be using the newer one whichever that may be?

Should I be creating Components or React Class to develop my UI?

I see some examples using Component. For example:

export default class ItemList extends Component {
  constructor(props) {

  //binding functions
  this.renderHeader = this.renderHeader.bind(this);
  this.renderRow = this.renderRow.bind(this);

    super(props);
    this.state = {
      dataSource: this.props.state.planDataSource,
      planName: null
    }
}

And others using

var ItemList = React.createClass({

  getInitialState: function() {
    return {
      dataSource: this.props.state.planDataSource,
      planName: null
    };
  },

I am learning react-native by example and I am confused as to which is preferred.

I recently converted a React class to a component and discovered that the "this" pointer does not work because React classes used autobinding and Components require explicit binding.

3 Answers
Related