Last active
June 2, 2017 13:27
-
-
Save javarouka/1ecea1df78d5cf26839023bcca98bc55 to your computer and use it in GitHub Desktop.
This file contains 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, { Component } from 'react' | |
import ReactDOM from 'react-dom' | |
function applyClipboard(element, selector) { | |
// implements ... | |
} | |
/** | |
* @Usage | |
* class SomeComponent extends Component {} | |
* export default clipboard('[clip-target]')(SomeComponent) | |
*/ | |
export default function clipboard(selector) { | |
return (Component) => { | |
return class ClipboardDecorated extends Component { | |
componentDidMount() { | |
applyClipboard(ReactDOM.findDOMNode(this), selector); | |
} | |
componentDidUpdate() { | |
applyClipboard(ReactDOM.findDOMNode(this), selector); | |
} | |
render() { | |
return ( | |
<Component {...this.props} /> | |
); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment