Skip to content

Instantly share code, notes, and snippets.

@Evavic44
Created March 22, 2022 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Evavic44/960741934894b0299869dc031b765158 to your computer and use it in GitHub Desktop.
Save Evavic44/960741934894b0299869dc031b765158 to your computer and use it in GitHub Desktop.
Widget for GitHub comments using Utterance widget
import React, { Component } from "react";

export default class Comments extends Component {
	constructor(props) {
		super(props);
		this.commentBox = React.createRef();
	}

	componentDidMount() {
		let scriptEl = document.createElement("script");
		scriptEl.setAttribute("src", "https://utteranc.es/client.js");
		scriptEl.setAttribute("crossorigin", "anonymous");
		scriptEl.setAttribute("async", true);
		scriptEl.setAttribute("repo", "evavic44/rocketmeme");
		scriptEl.setAttribute("issue-term", "Reviews & Feedback");
		scriptEl.setAttribute("theme", "github-light");
		this.commentBox.current.appendChild(scriptEl);
	}

	render() {
		return (
			<div style={{ width: "100%" }}>
				<div ref={this.commentBox}></div>
			</div>
		);
	}
}
import Comments from "..src...";
// Add this to the preffered page you want utterance to show on.
<Comments />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment