mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add ReactProps.func
This adds ReactProps.func so people don't need to write the slightly-more-cryptic ReactProps.instanceOf(Function). We should have had this all along.
This commit is contained in:
committed by
Paul O’Shannessy
parent
259392035d
commit
54d3134da2
@@ -73,6 +73,7 @@ var Props = {
|
||||
|
||||
array: createPrimitiveTypeChecker('array'),
|
||||
bool: createPrimitiveTypeChecker('boolean'),
|
||||
func: createPrimitiveTypeChecker('function'),
|
||||
number: createPrimitiveTypeChecker('number'),
|
||||
object: createPrimitiveTypeChecker('object'),
|
||||
string: createPrimitiveTypeChecker('string'),
|
||||
|
||||
@@ -56,6 +56,7 @@ describe('Primitive Types', function() {
|
||||
it("should not throw for valid values", function() {
|
||||
expect(typeCheck(Props.array, [])).not.toThrow();
|
||||
expect(typeCheck(Props.bool, false)).not.toThrow();
|
||||
expect(typeCheck(Props.func, function() {})).not.toThrow();
|
||||
expect(typeCheck(Props.number, 0)).not.toThrow();
|
||||
expect(typeCheck(Props.object, {})).not.toThrow();
|
||||
expect(typeCheck(Props.string, '')).not.toThrow();
|
||||
|
||||
Reference in New Issue
Block a user