statics

statics

object statics

The statics object allows you to define static methods that can be called on the component class. For example:

var MyComponent = React.createClass({
  statics: {
    customMethod: function(foo) {
      return foo === 'bar';
    }
  },
  render: function() {
  }
});

MyComponent.customMethod('bar');  // true

Methods defined within this block are static, meaning that you can run them before any component instances are created, and the methods do not have access to the props or state of your components. If you want to check the value of props in a static method, have the caller pass in the props as an argument to the static method.

doc_React
2016-06-23 03:32:30
Comments
Leave a Comment

Please login to continue.