A collection of react helper functions.
npm install react-helper-pack
bindMethods (instance, [methods])
- instance Current React Component instance (usually this)
- methods (optional) array of methods to bind. If none is given all methods will be bound
import { bindMethods } from 'react-helper-pack';
class MyComponent extends Component {
constructor () {
super();
bindMethods(this, ['onClick']);
}
dontBindThisMethod () {
// ... this method will not be bound
}
onClick (ev) {
// ... do something here
}
render () {
// ... render component
}
}
filterEvents (props, [ignore])
- props A props object to filter react events
- ignore (optional) array of events not to filter
import { filterEvents } from 'react-helper-pack';
const props = {
disabled: true,
onClick: myOnClickFunction,
onMouseUp: myMouseFunction
};
let events = filterEvents(props, ['onMouseUp']);
console.log(events);
// Returns:
// { onClick: myOnClickFunction }
- Fix typo in Media Events
- Add bindMethods
- Add package name to errors
- Add build script should work fine now from npm
- fix exporting