From d70a0d1c90f015238993465a26c754689fb1890a Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Thu, 13 Feb 2014 22:13:39 -0800 Subject: [PATCH] Add simple docs on statics to reference section Fixes #1056. --- docs/ref-03-component-specs.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/ref-03-component-specs.md b/docs/ref-03-component-specs.md index 7fe23818..b024020d 100644 --- a/docs/ref-03-component-specs.md +++ b/docs/ref-03-component-specs.md @@ -67,6 +67,31 @@ The `mixins` array allows you to use mixins to share behavior among multiple com +### statics + +```javascript +object statics +``` + +The `statics` object allows you to define static methods that can be called on the component class. For example: + +```javascript +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. + + ### displayName ```javascript