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

A solution for mixins #174

Closed
pho3nixf1re opened this issue Jun 14, 2015 · 1 comment
Closed

A solution for mixins #174

pho3nixf1re opened this issue Jun 14, 2015 · 1 comment

Comments

@pho3nixf1re
Copy link

Is there a way to share functionality like with a ReactMixin? Or perhaps there is a better pattern than that? I noticed an interesting proposal in #19 from awhile back but that has not been implemented yet, or at least not as described.

@anthonyshort
Copy link
Owner

Because components are just objects, you don't need built-in mixin functionality. You can extend the object or compose functions instead. For example:

// extending
import extend from 'extend'
import mySharedStuff from './shared'

let component = extend({}, mySharedStuff, {
  render: function(){
     // etc.
  }
})
// extending
import compose from 'compose'
import validation from './shared'

let render = compose(validation, function({ props, state }) {
  // etc.
})

export { render }

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