Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resurrect decorators #15

Merged
merged 1 commit into from
Jun 3, 2015
Merged

Resurrect decorators #15

merged 1 commit into from
Jun 3, 2015

Conversation

ooflorent
Copy link
Contributor

Bring back decorator APIs:

import { container, root } from 'redux';

@root
class App {
  render() {
    return (
      <Counter />
    );
  }
}

@container({
  actions: { increment, decrement },
  stores: counterStore
})
class Counter {
  static propTypes = {
    increment: PropTypes.func.isRequired,
    decrement: PropTypes.func.isRequired,
    counter: PropTypes.number.isRequired
  };

  render() {
    const { increment, decrement, counter } = this.props;
    return (
      <p>
        Clicked: {counter} times
        {' '}
        <button onClick={() => increment()}>+</button>
        {' '}
        <button onClick={() => decrement()}>-</button>
      </p>
    );
  }
}

@@ -1,7 +1,7 @@
import React, { Component, PropTypes } from 'react';
import createDispatcher from './createDispatcher';

export default function root(DecoratedComponent) {
export default function Root(DecoratedComponent) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a typo here.

@ooflorent
Copy link
Contributor Author

@gaearon What do you think of it? I haven't done the addons stuff.

@gaearon
Copy link
Contributor

gaearon commented Jun 3, 2015

Looks good to me. Let me play with it & get back to you!

@gaearon gaearon merged commit e0a00cd into reduxjs:master Jun 3, 2015
@gaearon
Copy link
Contributor

gaearon commented Jun 3, 2015

Out in 0.4.0.

@ooflorent ooflorent deleted the resurrect-decorators branch June 3, 2015 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants