ReactJS component PropTypes – specify a function type with a set number parameters
You could try using a custom validator:
1 2 3 4 5 6 7 8 9 10 | propTypes : { onClick : function(props, propName, componentName) { var fn = props[propName]; if(!fn.prototype || (typeof fn.prototype.constructor !== 'function' && fn.prototype.constructor.length !== 2)) { return new Error(propName + 'must be a function with 2 args'); } } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.