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

Scrap Marty.Component in favour of Marty.createContainer #204

Closed
jhollingworth opened this issue Mar 19, 2015 · 4 comments
Closed

Scrap Marty.Component in favour of Marty.createContainer #204

jhollingworth opened this issue Mar 19, 2015 · 4 comments
Milestone

Comments

@jhollingworth
Copy link
Contributor

FB just blogged about how Relay works.

This makes a lot of sense and gets around a load of the issues with Marty.Component (e.g. contextTypes, having to inherit from a base class).

I suggest we scrap Marty.Component altogether and just replicate Relay.createContainer

class User extends React.Component {
  render() {
    return this.props.user.when({
       ...
    });
  }  
}

module.exports = Marty.createContainer(User, {
  listenTo: UserStore,
  user() {
    return UserStore.getUser(123)
  }
});
@bigardone
Copy link
Contributor

So this means that:

  • Components will use props received from containers instead of state.
  • Stores state changes will affect containers.
  • State mixins are not longer needed.

Is this right?

@jhollingworth
Copy link
Contributor Author

Yeah, spot on. It provides a clear separation with between the component and fetching state (no more when in you're components) plus opens some more complex scenarios (e.g. only certain properties are needed before rendering, setting default values when pending, etc).

The PR has an expanded example of how its going to look.

@jhollingworth
Copy link
Contributor Author

Although, I should say state mixins aren't being depreciated just yet (maybe v0.11). We're just recommending you use containers as they are better.

@bigardone
Copy link
Contributor

Awesome, it looks really useful.

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

No branches or pull requests

2 participants