0.2.1 • Published 7 years ago

react-helper-pack v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

react-helper-pack

A collection of react helper functions.

Install

npm install react-helper-pack

Docs

bindMethods

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

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 }

Changelog

0.2.0

  • Add bindMethods
  • Add package name to errors

0.1.2

  • Add build script should work fine now from npm

0.1.1

  • fix exporting
0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago