Skip to content

Commit

Permalink
Checking if window.DISQUS exists before reset (#9)
Browse files Browse the repository at this point in the history
* Checking if window.DISQUS exists before reset

* Remove unnecessary brackets
  • Loading branch information
alexmateos authored and ryanvalentin committed Mar 5, 2018
1 parent 5ec3eaf commit dbabf28
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DiscussionEmbed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DiscussionEmbed extends React.Component {

loadInstance() {
const doc = window.document;
if (doc.getElementById('dsq-embed-scr')) {
if (window && window.DISQUS && doc.getElementById('dsq-embed-scr')) {
window.DISQUS.reset({
reload: true,
config: this.getDisqusConfig(this.props.config),
Expand All @@ -48,7 +48,9 @@ export class DiscussionEmbed extends React.Component {
cleanInstance() {
const doc = window.document;
removeScript('dsq-embed-scr', doc.body);
window.DISQUS.reset({});
if (window && window.DISQUS)
window.DISQUS.reset({});

try {
delete window.DISQUS;
} catch (error) {
Expand Down

0 comments on commit dbabf28

Please sign in to comment.