react-stampit icon indicating copy to clipboard operation
react-stampit copied to clipboard

API

Open troutowicz opened this issue 9 years ago • 12 comments

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

troutowicz avatar May 24 '15 16:05 troutowicz

Definitely .compose()

ericelliott avatar May 24 '15 16:05 ericelliott

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();

troutowicz avatar May 24 '15 16:05 troutowicz

I don't understand what you mean. Could you provide a more complete use case?

ericelliott avatar May 24 '15 16:05 ericelliott

import stampit from 'react-stampit';

const nonReactStampMixin = stamit.stampit({
  foo() {}
});

const reactStampMixin = stampit(Render, {
  propTypes: {}
});

const reactStamp = stampit(Render, {
  render() {}
}).compose(nonReactStampMixin, reactStampMixin);

troutowicz avatar May 24 '15 17:05 troutowicz

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';?

ericelliott avatar May 24 '15 18:05 ericelliott

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.

troutowicz avatar May 24 '15 19:05 troutowicz

:+1:

ericelliott avatar May 24 '15 19:05 ericelliott

Added the compose utility method.

troutowicz avatar May 24 '15 21:05 troutowicz

@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.

troutowicz avatar May 25 '15 23:05 troutowicz

@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!

troutowicz avatar Jun 05 '15 02:06 troutowicz

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:

ericelliott avatar Jun 05 '15 06:06 ericelliott

Sounds great! You're welcome, I'm glad they were accepted.

troutowicz avatar Jun 05 '15 10:06 troutowicz