Expose decorate to plugins #1261

Merged
merged 1 commit into from Jan 1, 2017

Projects

None yet

3 participants

@timneutkens
Collaborator

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>
      )
    }
  }
}
@timneutkens timneutkens Expose decorate to plugins
44c1124
@albinekb
albinekb approved these changes Dec 18, 2016 edited View changes

Awesome! Super neat 😎

@caesar caesar referenced this pull request in henrikdahl/hyper-statusline Dec 19, 2016
Closed

Plugins #1

@rauchg rauchg merged commit f6eaef9 into zeit:master Jan 1, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@timneutkens timneutkens deleted the timneutkens:expose-decorate-plugin branch Jan 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment