Base React component extended by some helpful features
Usage
;; // with decorators @baseComponent Component //... your component code // or without decoratorsComponent //... your component code;
Available features
._refCallback(refKey)
String refs are deprecated. So you need to provide function bound to your component. Or just ...
{ return <button ref=this></button>;}
._bind(handlerName1, [handlerName2, ...])
Helps you to bind your handlers more comfortably
Component { // ... your code this; } { // ... your click handler } { return <button onClick=thishandleClick></button>; };
._bindToState(stateKey, [valueResolver])
Often you have some form inputs. And every time their values changed you have to go and set it to state of your component. Stop it!
._bindToState
creates a handler which takes result of valueResolver
function and writes it to this.state.<stateKey>
.
By default valueResolver
equals
etargetvalue
So if it is your case just omit the second argument.
And a couple of examples:
{ return <MySuperEmailControl onChange=this/>;} { return <input type="text" placeholder="Please enter your email" onChange=this/>;}