React creating a MixIn

- 1 answer

Ad

I wanted to create a mixin for react. Using a simplified example - My goal is whenever an attribute/prop of TOOLTIP is found, it should add as child to that element my component of React.createElement(Tooltip, {}, this.props.TOOLTIP)

This hasnt been made clear on the official API page ( http://facebook.github.io/react/docs/forms.html ), or maybe I missed something, but is this possible?

Thanks

Ad

Answer

Ad

This cannot be done using mixins as they can't have a render method. You need Higher Order Components for this.

Ad
source: stackoverflow.com
Ad