Skip to content

Instantly share code, notes, and snippets.

@cometkim
Created March 2, 2018 09:51
Show Gist options
  • Save cometkim/c62a8952b026213081005c6ea01163b8 to your computer and use it in GitHub Desktop.
Save cometkim/c62a8952b026213081005c6ea01163b8 to your computer and use it in GitHub Desktop.
React Utteranc 댓글 컴포넌트
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