I'm a big fan of decorators, but it seems like much of the React/Redux world is overly class-decorator happy. It's really common to define properties in a decorator which would be much easier to read, IMO, as static or instance properties. I'd rather read something more like this:
@kea // kicks off the meta-programming to read the statics below
export default class Counter extends Component {
static actions = {
increment: (amount) => ({ amount }),
decrement: (amount) => ({ amount }),
};
static reducers = {
counter: [0, PropTypes.number, {
[this.actions.increment]: (state, payload) => state + payload.amount,
[this.actions.decrement]: (state, payload) => state - payload.amount
}],
};
static selectors = ({ selectors }) => ({
doubleCounter: [
() => [selectors.counter],
(counter) => counter * 2,
PropTypes.number,
],
});
render () {
const { counter, doubleCounter } = this.props
const { increment, decrement } = this.constructor.actions
return (
<div className='kea-counter'>
Count: {counter}<br />
Doublecount: {doubleCounter}<br />
<button onClick={() => increment(1)}>Increment</button>
<button onClick={() => decrement(1)}>Decrement</button>
</div>
)
}
}