Composables for React.
npm install react-stamp --save
What is composition?
HOCs.But I like
So do I! HOC factories provide a functional API for component composition and stamp composition can be a nice complement. If the goal is to be functional and avoid APIs that expose
class and it's pseudo-classical behavior, why use
class at all?
No. The only similarity is that both provide forms of object composition.
react-stamp decouples the relationship between component and mixin while being less opinionated. This provides greater flexibility.
So what is this?
react-stamp is the result of wondering about what other ways a React component could be represented. Stamps are a cool concept and more importantly have proven to be a great alternative to
React.createClass and the ES2015
class due to their composability.
react-stamp exports a function that accepts one parameter, the React library.
This method converts React's
Component constructor function into a stamp. To create a React component, we pass a descriptor object to the stamp's
interface ReactDescdisplayName?: Stringinit?: Functionstate?: Objectstatics?: ObjectcontextTypes?: ObjectchildContextTypes?: ObjectpropTypes?: ObjectdefaultProps?: Object...methods?: Functionstamp Stamp
The most powerful feature of stamps is their composability. Any number of stamps can be combined into a new stamp which inherits each passed stamp's behavior. This behavior is suitable for React since
class is being pushed as the new norm and does not provide an idiomatic way to utilize mixins. (classical inheritance 😞).