JSFiddle - React, Tailwind, and code Playground
JavaScript
inputGuardedComponent.prototype.setPredicate = function(predicate) {
this.predicate = predicate;
}
inputGuardedComponent.prototype.onChange = function(handler) {
let handlerWithPredicate = function(event) {
if (this.predicate(this._element.value)) {
handler(event)
}
}
this._element.addEventListener('change', handlerWithPredicate)
}