Created
March 2, 2018 09:51
-
-
Save cometkim/c62a8952b026213081005c6ea01163b8 to your computer and use it in GitHub Desktop.
React Utteranc 댓글 컴포넌트
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 * as React from 'react' | |
interface UtterancProps { | |
repo: string | |
branch: string | |
issueTerm: string | |
} | |
export default class Utteranc extends React.PureComponent<UtterancProps> { | |
instance: HTMLDivElement = null; | |
componentDidMount() { | |
const utteranc = document.createElement('script') | |
utteranc.src = 'https://utteranc.es/client.js' | |
utteranc.async = true | |
utteranc.setAttribute('repo', this.props.repo) | |
utteranc.setAttribute('branch', this.props.branch) | |
utteranc.setAttribute('issue-term', this.props.issueTerm) | |
this.instance.appendChild(utteranc) | |
} | |
render() { | |
return <div ref={el => (this.instance = el)} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment