Created
April 20, 2019 15:32
-
-
Save msikma/6185b2fb6f0093f759d3538d5d6a2431 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
// Decorator that passes on a 'message' property to a class. | |
const addMessage = (str) => (component) => { | |
component.prototype.message = str | |
} | |
@addMessage('Hello world!') | |
export default class DecoratorTest extends React.PureComponent { | |
render() { | |
return <div>{ this.message }</div> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment