Skip to content

Comments

Expose decorate to plugins#1261

Merged
rauchg merged 1 commit intovercel:masterfrom
timneutkens:expose-decorate-plugin
Jan 1, 2017
Merged

Expose decorate to plugins#1261
rauchg merged 1 commit intovercel:masterfrom
timneutkens:expose-decorate-plugin

Conversation

@timneutkens
Copy link
Member

This adds the ability to require('hyper/decorate') to register your own decorators from plugins 🌟
Will allow plugins to create a React component that can be extended by other plugins.

Example:

import React, {Component} from 'react'
import decorate from 'hyper/decorate'

class MyComponent extends Component {
  render () {
    return (<div>My Component</div>)
  }
}

export default decorate(MyComponent, 'MyComponent')

Then in plugin code:

import React, {Component} from 'react'
export function decorateMyComponent (MyComponent) {
  return class extends Component {
    render () {
      return (
        <div>
          <MyComponent {...this.props}>
          <div>Something else</div>
        </div>
      )
    }
  }
}

Copy link
Contributor

@albinekb albinekb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Super neat 😎

@rauchg rauchg merged commit f6eaef9 into vercel:master Jan 1, 2017
@timneutkens timneutkens deleted the expose-decorate-plugin branch January 1, 2017 12:23
@chabou chabou mentioned this pull request Jun 4, 2018
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

Successfully merging this pull request may close these issues.

4 participants