Giter Site home page Giter Site logo

disqus-react's Introduction

disqus-react

npm version

A package for integrating Disqus services into React applications.

Installation

Using npm:

$ npm install --save disqus-react

Using yarn:

$ yarn add disqus-react

Usage

DiscussionEmbed

This is the component that will load the main Disqus comments section.

import { DiscussionEmbed } from 'disqus-react';

<DiscussionEmbed
    shortname='example'
    config={
        {
            url: this.props.article.url,
            identifier: this.props.article.id,
            title: this.props.article.title,
            language: 'zh_TW' //e.g. for Traditional Chinese (Taiwan)	
        }
    }
/>

This component is limited to one instance in the DOM at a time and will handle updates to both the config and shortname props and reload appropriately with the new discussion thread.

DiscussionEmbed with SSO

This is an example for setting up the DiscussionEmbed component with SSO. This example config is also used on the Disqus React SSO example found here: https://disqus-sso-react-demo.glitch.me/.

import { DiscussionEmbed } from 'disqus-react';

<DiscussionEmbed
    shortname='example'
    config={
        {
            url: this.props.article.url,
            identifier: this.props.article.id,
            title: this.props.article.title,
            language: 'zh_TW', //e.g. for Traditional Chinese (Taiwan)
            apiKey: '',
            sso: {
                name: 'SampleNews',
                button: 'http://example.com/images/samplenews.gif',
                icon: 'http://example.com/favicon.png',
                url: 'http://example.com/login/',
                logout: 'http://example.com/logout/',
                profile_url: 'http://example.com/profileUrlTemplate/{username}',
                width: '800',
                height: '400',
            }
        }
    }
/>

CommentCount

This component will display the comment count for the Disqus thread associated with the provided config.

import { CommentCount } from 'disqus-react';

<CommentCount
    shortname='example'
    config={
        {
            url: this.props.article.url,
            identifier: this.props.article.id,
            title: this.props.article.title,
        }
    }
>
    {/* Placeholder Text */}
    Comments
</CommentCount>

Multiple instances of this component can be included on the same page with different config variables (e.g. an article list showing the comment count for each). However, all threads on the site must be under the same primary site shortname. If the component receives a new shortname, all instances will be reset with counts for threads matching the updated site.

CommentEmbed

This component can be used to embed a Disqus comment into your page.

import { CommentEmbed } from 'disqus-react';

<CommentEmbed
    commentId={this.props.article.featuredCommentId}
    showMedia={true}
    showParentComment={true}
    width={420}
    height={320}
/>

Multiple instances of this component may be include on the same page with different commentId variables and does not require that the embedded comment be under the same primary site shortname.

Recommendations

This component can be used to embed Disqus Recommendations into your page.

import { Recommendations } from 'disqus-react';

<Recommendations 
    shortname='example'
    config={
        {
            url: this.props.article.url,
            identifier: this.props.article.id,
            title: this.props.article.title,
        }
    }
/>

The config prop is optional and is used to prevent any discussions on the current page from being included in the recommendations. This component is limited to one instance in the DOM at a time and will handle updates to the shortname prop and reload appropriately with recommended pages for the new forum shortname.

Contributing

If you'd like to contribute to this package feel free to submit a bug report, feature request, or pull request. Though we would ask that you first read through the contributing guidelines.

disqus-react's People

Contributors

alexmateos avatar arteagabriel avatar camilasousa avatar chrisjtang avatar dependabot[bot] avatar gddh avatar hsh2001 avatar icandivideby0 avatar lavrton avatar lmammino avatar marcofranssen avatar mateja176 avatar poohitan avatar romantsegelskyi avatar ryanvalentin avatar trend-kevin-c-chen avatar tterb avatar zhangyijiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

disqus-react's Issues

[TypeScript] Module '"disqus-react"' has no exported member 'Recommendations' ts(2614)

Recommendations component was introduced in PR #94 (which is great!) but it doesn't seem to have type definitions (like other components do).

To Reproduce

Import the component:

import { Recommendations } from "disqus-react";

And this TypeScript error is displayed:

Module '"disqus-react"' has no exported member 'Recommendations'. ts(2614)

Specifications:

  • OS: macOS Big Sur (11.4)
  • Package version: 1.1.0
  • Node version: 14.17.0

<link ... in Head Tag Not Cleaned

I'm using Nextjs,

When I navigate from a page with no comments to a page with comments repeatedly, Disqus keeps inserting the <link... tag in .

image

Script rendered twice

dsq-embed-scr is being added twice to the DOM. This is captured as invalid HTML because of id used being the same.

image

image

It seems it is due to componentDidUpdate being called right after componentDidMount (nothing wrong here). However window.DISQUS is still undefined, as script is certainly still loading. Therefore, it tries to load the script again.

Deprecation warning

I get this when I run the module. I think you need to replace componentWillMount

Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

  • Move code from componentWillMount to componentDidMount (preferred in most cases) or the constructor.

Please update the following components: DiscussionEmbed

Add/Expose additional API offerings

Is your feature request related to a problem? Please describe.

It would be nice to be able to use other APIs available from Disqus (e.g. listMostActiveUsers, listMostLikedUsers, etc)

Describe the solution you'd like

Either a way to expose these APIs so we can build our own UI with the data, or create more exports for listMostActiveUsers, etc.

Cannot read property 'forumsFollowing' of undefined

Describe the bug

I'm not sure what the root cause of this bug is, but sometimes (often) when I try clicking the button on the Disqus component that opens the Disqus overlay, I get the error Cannot read property 'forumsFollowing' of undefined in my console. At this point nothing happens, but I cannot interact with my page any longer due to the error.

To Reproduce

It's happening just when the component loads, and I click the button next to the comment count that opens the overlay for my forum.

EDIT
On closer investigation, this bug appears to occur as a result of a button I have to load the discussion thread. If the component loads on start, it works fine, but if I have a conditional rendering that causes the discussion thread to only load when I click a button, then loading the overlay creates this bug. The conditional render looks like this:

        if(this.state.displayComments && this.state.disqusConfig) {
            const disqusConfig = this.state.disqusConfig;
            return <DiscussionEmbed shortname={disqusConfig.disqusShortName} config={disqusConfig.config} />;
        }

        return (
            <div className={styles.commentsButton}>
             <Button onClick={() => {this.setState({displayComments: true})}}>Load Comments</Button>
            </div>
        )

EDIT 2
The issue doesn't seem to be exclusive to the above scenario after all.

Expected behavior

The forum overlay opens without any errors.

Can we have multiple Disqus instances in SPA(react)?

Is your feature request related to a problem? Please describe.

Currently, library supports only one instance in the DOM for DiscussionEmbed component.

Describe the solution you'd like

I need multiple instances for DiscussionEmbed at one time. We are currently displaying 10 blogposts on a single page. Each blogpost will have its own Disqus instance.

Scroll not working

Anyone else cannot scroll when hovering over the component? I have my disqus wrapped in a div with width set to 100%

<div className={styles.discussion}>
          <DiscussionEmbed
            shortname="lengjai-com"
            config={props.disqusConfig}
          />
</div>

Can't resolve 'disqus-react'

Prebuilt package from npm seems to be broken. It's possible I've really broken something on my end, but I've spun up a couple of dummy projects and installed this and other packages from npm, and this one really does seem to be broken.

Steps to reproduce:

create-react-app my-application
cd my-application
npm install disqus-react

Open ./my-application/src/App.js and add import Disqus from 'disqus-react'; to imports.
npm run start

Can't set categories for my posts

Describe the bug

We are passing the categories to the post by the settings and it is not reflected on the Disqus dashboard.

To Reproduce

Steps to reproduce the behavior:

  1. First, setup the next code:
  <DiscussionEmbed
              shortname={DISQUS_SHORT_NAME}
              config={{
                url: postURL,
                identifier: slug,
                title: titleEn,
                /*
                Must be
                First tag: category
                Others: order does not matter
                */
                category_id: DISQUS_CATEGORIES[tags[0]?.slug],
              }}
            />

where:

const DISQUS_CATEGORIES = {
  general: "8664428",
  "front-end": "8755878",
  "back-end": "8755881",
  "deep-learning": "8755886",
  "video-games": "8755887",
}
  1. Publish a new blog on your site with front-end as first tag., it uses NextJS 10.0.5.
  2. Go to the dashboard, Tools > Discussions.
  3. The new post will have General as its category.

Expected behavior

As the first tag front-end, we should see it as the discussions category.

Specifications:

  • OS: OsX.
  • Package version: 1.0.10.
  • Node version: 12.x.

SSO Integration

I'm introducing Disqus in my platform as Business Account and I need to integrate ti Single Sign On feature. Is it possible to add this feature?

Should be okay adding the remote_auth_s3 and the public_key in the getDisqusConfig function

misleading demo code at homepage

troubleshooting says that URLs must match, while code hints that it should be url to article. So which option is the correct one? Should it be url to article or homepage?

image

the issue is that in any case, comments are not loading and there is no related issues in console or else.

image

Breaks Gatsby Build

Still breaking as of April 12, 2019 using GatsbyJS and Netlify see error below

ERROR
failed during stage 'building site': Build script returned non-zero exit code: 1

This is caused by same issue site builds fine without this package but as soon as i add it site breaks

also i can run / build on local env ie localhost:8000 but when i move to build in production with netlify i get that error

The comments thread is empty

I have installed this plugin on my gatsby site, the widget appears but the comments are zero in all posts. The site is hosted on a temporary domain but I tried to pass the short name and the original site URL combination as given below:

Here slug is the post slug

const siteUrl = 'https://www.domain.com/' + slug
const disqusprops = {
shortname: 'shortname',
config: { identifier: siteUrl, title },
};

<DiscussionEmbed
 shortname={disqusprops.shortname}
 config={disqusprops.config}
/>

Please advise what am I doing wrong, how can I fix this issue so that the post associated comments can be displayed.

Clarify relationship with Disqus, the company

In the package.json description, this package is described as the official Disqus React package. However, this is not mentioned on the GitHub repo description, nor in the README file, and the package is not published under the Disqus GitHub Organization https://github.com/disqus.

I think it would be useful to clarify how official this package is, and make it easier for developers to trust it out of the other Disqus React components that are out there.

Disqus SSO

I have looked through the FAQ and found no similar questions

Does this support SSO? I have seen a PR merge but I'm not able to use SSO. Am I doing something wrong?

<DiscussionEmbed
    shortname="SHORTNAME"
    config={{
      identifier: "IDENTIFIER",
      title: "TITLE",
      remoteAuthS3: " ",
      apiKey: "PUBLIC KEY",
    }}
  />

developer mode flag

how about prop developerMode={true/false}?
Trying to load comments at localhost. Can't enter dev mode or add localhost as valid domain.

image

image

TS Error: Statements not allowed in ambient contexts

Describe the bug

../node_modules/disqus-react/types/index.d.ts:7:2 - error TS1036: Statements are not allowed in ambient contexts. 7 };

To Reproduce

Import disqus-react on TS, unless there's some special integration bug going on.

Expected behavior

Should not have type error.

Screenshots

image

Specifications:

  • OS: Mac OS X
  • Package version: 1.0.8
  • Node version: 12.8.1
  • TypeScript version: 3.8.3

shouldComponentUpdate bug

Describe the bug

Even if the same props are passed the DiscussionEmbed rerenders.

To Reproduce

Steps to reproduce the behavior:

  1. Add discussion embed component with props
  2. rerender the parent component of discussion embed
  3. even if the same props are passed it rerenders the whole component (new iframe loads)

Expected behavior

in shouldComponentUpdate this.props === nextProps will always return false even if same values (which goes to shallowComparison then).
To fix replace it with something like this.props.identifier === nextProps.identifier && this.props.url === nextProps.url

I think there's a problem with shallowComparison.

Warning: componentWillUpdate has been renamed

Describe the bug

Error when using component.

To Reproduce

Steps to reproduce the behavior:

  1. Render Disqus.DiscussionEmbed component.

Expected behavior

No errors!

Screenshots

스크린샷 2020-01-28 오후 1 48 03

Specifications:

  • OS: macOS 10.15.2
  • Package version: ^1.0.7
  • Node version: v12.14.0

Additional context

When I use component, a warning appears. I think it need to update.

Warning: componentWillUpdate has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: DiscussionEmbed

DiscussionEmbed fails PropType Check for config Object, complains for String

Disregard. I'm novice.

Describe the bug

DiscussionEmbed's config prop says it would like a string not an object, fails proptype check

To Reproduce

Run disqus-react as of 9/8/2021 @ 2PM EDT

Expected behavior

I expected Disqus-React's DiscussionEmbed to load, but config complained about it being an object, and that it should be a string. PropType check fails

Screenshots

image

Specifications:

  • OS: Arch Linux
  • Package version: 1.1.2
  • Node version: 14.17.4

Additional context

Add any other context about the problem here.

url wrong: url has two slash so that cannot be directed to the right page.

Describe the bug

A clear and concise description of what the bug is.

url in xxx.disqus.com/admin/moderate/approved has two slash(//), which makes it unable to render the comment area. Besides, when using shared links, the same reason will make a same trouble. For more detials, please see here and here.

To Reproduce

Steps to reproduce the behavior:

  1. Go to casbin.org or crystal-lang.org
  2. leave a comment using disqus
  3. copy share link
  4. open share link
  5. The url will have two slash. For example: casbin.org//xxx/yyy/zz

Expected behavior

A clear and concise description of what you expected to happen.

The url should have only one slash. For example: "xxxxx.org/yy/zz"

Screenshots

If applicable, add screenshots to help explain your problem.

Please see the two PRs above.

Loading non-stop

Describe the bug

Non-stop loading

Screenshot from 2019-07-02 23-38-11

To Reproduce

Steps to reproduce the behavior:

  1. git clone https://github.com/mateja176/react-hot-starter.git
  2. cd react-hot-starter
  3. npm i
  4. npm start
  5. start http://localhost:3000/count

Expected behavior

Loading stops and comment count and discussion embed show up.

Screenshots

Screenshot from 2019-07-02 23-46-28

Screenshot from 2019-07-02 23-38-11

Specifications:

  • OS: Linux, Ubuntu 19.04
  • Package version: 1.0.6
  • Node version: v11.14.0

Additional context

Add any other context about the problem here.

Remove "Comments" string from the CommentCount component

Hi!

I want to remove the "Comments" string that is rendered with the comments count, i just want the integer part. Exists any way to get only the number of comments? Without the "comments" word? For internationalization matters will be very useful too.

Language support, category support

Can you maybe add language support (multilingual support for multilingual sites) and category_id support to the component? Also maybe typescript definitions would be a good idea, especially since not all functionality seems to be written down in the README file.

Transpile code distributed on NPM

Currently the NPM package ships with untranspiled source that includes JSX and ES6 modules. This means that developers will need to set up additional infrastructure to use this package. In addition, most setup today do not transpile node_modules content with the assumption that the package maintainer already does this.

It would be useful to run the code through Webpack to produce a ready-to-use file that can be dropped into the browser directly, and through Babel to produce a transpiled version that can be used with ES6 aware bundlers like Webpack 2 and Rollup. The topic is unfortunately more convoluted than it should be, but here are some resources I've found:

Weird bugs

So it is working on localhost/news/1. but when i go to the second news article which is localhost/news/2 it says We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

how is this its running off of the same code it shouldnt be any different

A cookie associated with a cross-site resource at http://links.services.disqus.com/ was set without the `SameSite` attribute.

Describe the bug

I integrated the disqus-react component in my project and I get the console warning:
A cookie associated with a cross-site resource at http://links.services.disqus.com/ was set without the SameSite attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

To Reproduce

Simply integrate the disqus-react and use Chrome to browse the site and look at the dev-console.

Expected behavior

No warnings.

DiscussionEmbed has some issues rendering to Html

Describe the bug

Disqus fails to load and displays following message on the page. This is probably caused by some things not rendering accordingly to HTML

We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

To Reproduce

I have embedded following component in my Next.js page. I'm running on React 17.

import { DiscussionEmbed } from "disqus-react";

export default function DisqusComment({ rootUrl, post }) {
  const disqusShortname = "myshortname";

  const disqusConfig = {
    url: `https://mydomain.com/${post.slug}`,
    identifier: post.slug,
    title: post.title,
    language: "en_US",
  };

  return <DiscussionEmbed shortname={disqusShortname} config={disqusConfig} />;
}

When looking in the html it shows following following output.

<div shortname="myshortname" config="[object Object]" id="disqus_thread">
  <iframe id="dsq-app4987" name="dsq-app4987" allowtransparency="true" frameborder="0" scrolling="no" 
                tabindex="0" title="Disqus" width="100%"
                src="https://disqus.com/embed/comments/?base=default&amp;f=undefined&amp;t_i=remove-files-from-git-history-using-git-filter-repo&amp;t_u=https%3A%2F%2Fmarcofranssen.nl%2Fremove-files-from-git-history-using-git-filter-repo&amp;t_e=Remove%20files%20from%20Git%20history%20using%20git-filter-repo&amp;t_d=Remove%20files%20from%20Git%20history%20using%20git-filter-repo&amp;t_t=Remove%20files%20from%20Git%20history%20using%20git-filter-repo&amp;s_o=default&amp;l=en_US#version=d263308ceb903a20735ee19a49738b60"
                style="width: 1px !important; min-width: 100% !important; border: none !important; overflow: hidden !important; height: 75px !important;" horizontalscrolling="no" verticalscrolling="no">
   </iframe>
</div>

Expected behavior

As seen in previous html output there is a undefined value in the f querystring parameter for the iframe src. Also the config="[object Object]" in the div doesn't seem to be rendered properly into the view as it probably should.

Screenshots

N.A.

Specifications:

  • OS: MacOS big Sur
  • Package version: 1.0.10
  • Node version: 15.5.1
  • React version: 17.0.1

Additional context

N.A.

Comment count not updating

Hi, I can't manage to show the comment count for some of my post. Comment count only shows when it has a comment and there's a newer post.
image

Multiple Disqus Boards with Unique ShortNames on one Page

Hello. I'm trying to add multiple disqus threads to one page where each one has a unique shortname. Below is my html and script attempts. I cannot get it to work. This is a single page with simply a list of topics on the left where a user can click the topic and on the right the disqus thread will show. Each disqus thread has a unique shortname. I can get the threads to show; however, the shortname is always the same (the first one loaded) on the top of the thread no matter which topic the user clicks on.

Is there a way to have multiple disqus threads with unique shortnames on one page?

-- foreach disqus board --
                      <li class="nav-item" role="presentation">
                        <button aria-controls="thread_{{forloop.index}}" aria-selected="true" class="nav-link active" data-bs-target="#thread_{{forloop.index}}" data-bs-toggle="tab" id="tab_{{disqus.forloop.index}}" onclick="reset('newid{{forloop.index}}', 'https://{{disqus.content}}.com/unique-path-to-article{{forloop.index}}/', '{{disqus.headline}}', 'en', '{{disqus.content}}');" role="tab" type="button">{{disqus.headline}}</button>
                      </li>
                      {% else %}
                      <li class="nav-item" role="presentation">
                        <button aria-controls="thread_{{forloop.index}}" aria-selected="true" class="nav-link" data-bs-target="#thread_{{forloop.index}}" data-bs-toggle="tab" id="tab_{{forloop.index}}" onclick="reset('newid{{forloop.index}}', 'https://{{disqus.content}}.com/unique-path-to-article{{forloop.index}}/', '{{disqus.headline}}', 'en', '{{disqus.content}}');" role="tab" type="button">{{disqus.headline}}</button>
                      </li>
                      {% endif %}{% endfor %}
-- end foreach --
 
 
<div id="disqus_thread">
                    &nbsp;
                  </div>
                  <script type="text/javascript">

                    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
                  
                    
                    /* * * DON'T EDIT BELOW THIS LINE * * * /
                    (function() {
                      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                      dsq.src = 'https://{{disqus.content}}.disqus.com/embed.js';
                      dsq.id = '1';
                      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);                    
                    })();
                    
                  var load = function (shortName) {
                    var dsq1 = document.createElement('script'); dsq1.type = 'text/javascript'; dsq1.async = true;
                      dsq1.src = 'https://' + shortName + '.disqus.com/embed.js';
                      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq1);
                    }
                  
                    /* * * Disqus Reset Function * * */
                    var reset = function (newIdentifier, newUrl, newTitle, newLanguage, shortName) {
                      window.location.reload();
                      load(shortName);
                    var disqus_shortname = shortName;
                    var disqus_identifier = 'newid1';
                    var disqus_url = 'https://' + shortName + '.com/unique-path-to-article-1/';
                    var disqus_config = function () {
                      this.language = "en";
                    ;
                      document.getElementById('disqus_thread').remove();
                      var div = document.createElement('div');
div.id = 'disqus_thread';
div.innerHTML = '&nbsp;';
document.body.appendChild(div);

                      DISQUS.reset({
            reload: true,
            config: function () {
                this.page.identifier = newIdentifier;
                this.page.url = newUrl;
                this.page.title = newTitle;
                this.language = newLanguage;
            }
        });

Typescript definitions missing from package

Describe the bug

I see that there is a typescript definitions file on the repo (the .d.ts file), but seems that is not being pushed on the package.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new React app with typescript support (npx create-react-app new-app --typescript)
  2. Add the disqus-react package (npm install disqus-react)
  3. Usin VSCode, open App.tsx and import the module (import Discus from 'disqus-react';)
  4. See tooltip error on the imported part.

Expected behavior

Typescript definitions should load

Screenshots

image

Specifications:

  • OS: Windows 10 1903 (latest available version), running Ubuntu via WSL
  • Package version: 1.0.5
  • Node version: 12.4.0

Additional context

Looking at the package contents, seems that the .d.ts file is missing!

url and identifier not making a difference, all comment boxes are the same

On my page, I render a list of posts with a "SHOW COMMENTS" button that reveals the DiscussionEmbed element:

  const postObjects = posts.map((p,index)=>{
    return (
        <div className="Post">

                <ReactMarkdown children={p.md}/>

                <button
                    onClick={()=>{
                        showComments(p.filename);
                    }}
                >
                    SHOW COMMENTS
                </button>

                { currentPost == p.filename &&  
                    <DiscussionEmbed
                        shortname={MY_DISQUS_SHORTNAME}
                        config={
                            {
                                url: `${MY_URL}#!${p.filename}`,
                                identifier: p.filename,
                                title: p.filename,
                            }
                        }
                    />                
                }

        </div>
    )
  });

here is the showComments function, which fires when the button is pressed, reset DISQUS from its window object and sets currentPost which then shows the DiscussionEmbed component that matches:

  const showComments = (filename) => {
      if (window.DISQUS) window.DISQUS.reset({
        reload: true,
        config: function () {  
          console.log(this);
          this.page.identifier = filename;  
          this.page.url = `${MY_URL}#!${p.filename}`;
        }
      });           
      setCurrentPost(filename);
  }

Anyway, all the comment blocks are the same / have the same comments. If I click the links to the comments contained in they have:

MY_URL

instead of

`MY_URL#!filename

What am I doing wrong?

Uncaught TypeError: Converting circular structure to JSON

Describe the bug

When using the DiscussionEmbed component this error is generated:

Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'ReactCompositeComponentWrapper'
    |     property '_instance' -> object with constructor 'App'
    --- property '_reactInternalInstance' closes the circle
    at JSON.stringify (<anonymous>)
    at b.Channel.h.sendMessage (embed.js:44)
    at e.<anonymous> (embed.js:45)
    at e.<anonymous> (embed.js:44)
    at e.<anonymous> (embed.js:44)
    at m (embed.js:44)
    at e.trigger (embed.js:44)
    at e.<anonymous> (embed.js:44)
    at m (embed.js:44)
    at b.Channel.trigger (embed.js:44)

It appears that embed.js is trying to stringify the config to use sendMessage, which includes a reference to the DIV container for the discussion, but that includes react references in it which are circular.

To Reproduce

Steps to reproduce the behavior:

  1. Clone this repo
  2. npm i && npm run build:example && npm start
  3. Navigate to examples, go to an article with a discussion
  4. See error in console

Expected behavior

No error

Specifications:

I assume it'd happen on a few platforms but mine specifically are:

  • OS: MacOS 10.15.7
  • Package version: latest
  • Node version: 12
  • Browser: Chrome 87

Additional context

Not sure if it's an issue with this package or disqus's embed.js no longer playing nice with react, either way it needs to be solved by disqus.

Complete installation docs and add to NPM

Would be great if this module was uploaded to NPM so users could use npm install disqus-react

Other disqus modules I have tried have not been working for me.

I had to install this one manually.

social share links (twitter/fb) point to localhost and not my domain

Describe the bug

A clear and concise description of what the bug is.
the link domain is localhost and NOT the site domain when the user clicks the social share links (twitter/facebook) within the disqus component.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'http://bit.ly/2KH3iYP'
  2. Scroll down to 'comments at the bottom of the page'
  3. Click on 'tweet or share'
  4. See opening window and link it creates in the social post.
  5. use link to go to page and see error

Expected behavior

I expect the share link to take the user to the page on my site

Screenshots

If applicable, add screenshots to help explain your problem.
screenshot of sharable link address

Specifications:

  • OS: osx 10.14.5
  • Package version: "^1.0.5"
  • Node version: v10.14.0

Additional context

Add any other context about the problem here.
I'm using it with gatsbyjs ver "^2.4.3"
using gatsby starter: https://gatsby-sseon-starter.netlify.com/

Component style not updating

Hi,
I'm using disqus-react with this gatsbyjs starter project

The problem is when I use the theme switcher the styles for disqus-react don't update without a page refresh. I tried passing the theme name into react-disqus as a prop to force an update but that didn't work:

<DiscussionEmbed theme={themeName} shortname={disqusShortname} config={disqusConfig} />

Any thoughts on how to force the styles to update?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.