This package has been deprecated

Author message:

revenge is deprecated. For @pure use React.PureComponent instead. For @skinnable use react-skinnable

revenge

0.4.5 • Public • Published

A collection of small React Component helpers

@pure

mark a Component as pure (perf)

import { pure } from 'revenge';
 
@pure // will add a default shouldComponentUpdate implementation
class UserCard extends React.Component {}

@skinnable()

split logic and rendering (testability)

import { skinnable } from 'revenge';
 
@skinnable() // or @skinnable(mytemplate)
class UserCard extends React.Component {
 
  getLocals() { // logic here
    return {
      name: this.props.user.name;
    };
  }
 
  template(locals) { // rendering here
    return <p>{locals.name}</p>;
  }
 
}

@skinnable(contains(Component))

wrap "template" components in a "smart/container" component

import { skinnable, contains } from 'revenge';
 
const UserCard = ({ name }) => <p>{name}</p>;
 
@skinnable(contains(UserCard))
class UserCardContainer extends React.Component {
  getLocals() {
    // ...complex logic to obtain data...
    return { name };
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i revenge

Weekly Downloads

2,016

Version

0.4.5

License

ISC

Last publish

Collaborators

  • pedrodim
  • marcopiii
  • gabro
  • veej
  • giogonzo
  • tpetrucciani
  • malpenzibo
  • federico.ercoles