diff --git a/src/core/ReactDescriptor.js b/src/core/ReactDescriptor.js index 1850d05118..b0f16da7bf 100644 --- a/src/core/ReactDescriptor.js +++ b/src/core/ReactDescriptor.js @@ -93,7 +93,15 @@ function proxyStaticMethods(target, source) { if (source.hasOwnProperty(key)) { var value = source[key]; if (typeof value === 'function') { - target[key] = value.bind(source); + var bound = value.bind(source); + // Copy any properties defined on the function, such as `isRequired` on + // a PropTypes validator. (mergeInto refuses to work on functions.) + for (var k in value) { + if (value.hasOwnProperty(k)) { + bound[k] = value[k]; + } + } + target[key] = bound; } else { target[key] = value; } diff --git a/src/core/__tests__/ReactDescriptor-test.js b/src/core/__tests__/ReactDescriptor-test.js index 8cbff0ac3c..d7ef12d950 100644 --- a/src/core/__tests__/ReactDescriptor-test.js +++ b/src/core/__tests__/ReactDescriptor-test.js @@ -63,4 +63,16 @@ describe('ReactDescriptor', function() { expect(test.foo).toHaveBeenCalledWith(a, b, c); }); + it('allows the use of PropTypes validators in statics', function() { + var Component = React.createClass({ + render: () => null, + statics: { + specialType: React.PropTypes.shape({monkey: React.PropTypes.any}) + } + }); + + expect(typeof Component.specialType).toBe("function"); + expect(typeof Component.specialType.isRequired).toBe("function"); + }); + });