react-stampit
react-stampit copied to clipboard
API
Let's discuss what the final API should look like. Do we want to include any of stampit's utility methods?
Public Stamp Interface ~~- [ ] stamp.methods~~ ~~- [ ] stamp.state~~ ~~- [ ] stamp.enclose~~
- [x] stamp.compose
Utility Methods
- [x] stampit.compose
- [x] stampit.isStamp
Definitely .compose()
I'm also thinking of a utility method that makes the core stampit library available, for times when a mixin may not need to be a React component. Would eliminate the need for importing react-stampit
and stampit
.
import stampit from 'react-stampit'
const mixin = stampit.stampit();
I don't understand what you mean. Could you provide a more complete use case?
import stampit from 'react-stampit';
const nonReactStampMixin = stamit.stampit({
foo() {}
});
const reactStampMixin = stampit(Render, {
propTypes: {}
});
const reactStamp = stampit(Render, {
render() {}
}).compose(nonReactStampMixin, reactStampMixin);
Browserify auto-dedupes and npm dedupes in v3+.
Don't you think it makes more sense for people who want direct stampit access to just import stampit from 'stampit';
?
What you are saying does make total sense, what I was proposing was nothing more than a convenience method. I was considering the use case where a module may have a reason to have a non-react mixin stamp AND and a react stamp in the same file... but that may not be a use case to worry much about. I'll leave the method out.
:+1:
Added the compose
utility method.
@ericelliott
~~Thoughts on deep merging React static props at composition? We would exclude defaultProps
due to perf reasons.~~
~~So this feature would apply to:~~ ~~* contextTypes~~ ~~* childContextTypes~~ ~~* propTypes~~
Created #2 with more details on my proposed composition implementation.
@ericelliott Merged PR #2, composition should be pretty much fully functional for React. Let me know if you see anything missing or have other ideas!
This API is looking great so far. I'm going to start using it in my production apps and see how it works for me.
BTW, thanks for helping to get those issues resolved in React. =)
:+1:
Sounds great! You're welcome, I'm glad they were accepted.