Comments (4)
@edouardr Could you provide the steps to reproduce this issue?
from disqus-react.
hey @tterb in my case, I have the following setup:
- GatsbyJS 2.9.4
- disqus-react 1.0.5
I have a component that looks like below:
import React from 'react';
import { DiscussionEmbed } from 'disqus-react';
import PropTypes from 'prop-types';
import useCurrentPage from '../../hooks/useCurrentPage';
import styles from './disqus.module.scss';
const Disqus = React.memo(function Disqus({ siteUrl }) {
const { currentPage } = useCurrentPage();
if (!process.env.DISQUS_SHORTNAME) {
return null;
}
const disqusConfig = {
identifier: currentPage.fields.codename,
title: currentPage.elements.jumbotron__title.value,
url: `${siteUrl}${currentPage.fields.language}/${currentPage.fields.slug}`,
};
return (
<div className={styles.comments}>
<DiscussionEmbed
shortname={process.env.DISQUS_SHORTNAME}
config={disqusConfig}
/>
</div>
);
});
Disqus.propTypes = {
siteUrl: PropTypes.string,
};
export default Disqus;
And a template that looks roughly like this:
import React from 'react';
import PropTypes from 'prop-types';
import { graphql } from 'gatsby';
import { getItemPerLanguage } from '../utils/templateHelper';
import ArticleHeader from '../components/Article/header';
import Disqus from '../components/Disqus/disqus';
import Gallery from '../components/Gallery/gallery';
import Header from '../components/Header/header';
import Layout from '../components/Layout/layout';
import '../components/SEO/SEO';
import useCurrentPage from '../hooks/useCurrentPage';
import useLang from '../hooks/useLang';
import BackToTop from '../components/Article/backToTop';
const Article = React.memo(function Article({ data, pageContext }) {
const { definePage } = useCurrentPage();
const { defineLang } = useLang();
const item = getItemPerLanguage(
pageContext.language,
currentArticle,
data.site
);
React.useEffect(() => {
defineLang(pageContext.language);
definePage(item);
}, []);
return (
<Layout>
<Header />
<article>
<ArticleHeader article={item} />
<div className="columns">
<div className="column is-offset-2 is-8">
<section className="section ">
<div
className="content is-large"
dangerouslySetInnerHTML={{
__html: item.elements.body_text.value,
}}
/>
</section>
</div>
</div>
<div className="container">
<Gallery images={item.elements.images.value} />
<Disqus siteUrl={item.site.siteMetadata.siteUrl} />
</div>
<BackToTop />
</article>
</Layout>
);
});
Article.propTypes = {
data: PropTypes.object,
pageContext: PropTypes.object,
};
export default Article;
When the above code loads, I get the embed script loaded twice as mentioned previously.
from disqus-react.
@edouardr Thanks for the info, Do you have a public repo for this site that I could use to try to reproduce this issue on my end and test out the solution in your PR #26?
If not, I can try using the code you provided but it maybe difficult since it relies on external hooks that could potentially be impacting the functionality.
from disqus-react.
@tterb I don't have right now, but I should be able to set a CodePen for it or a dummy repo. Will let you know as soon as I have it.
from disqus-react.
Related Issues (20)
- How do I get the image to load in the preview part of the Disqus homepage? HOT 2
- React 18 Support HOT 3
- Got a bunch of error when using disquss with Nextjs also got a CORS HOT 3
- No new release after react 18 upgrade? HOT 1
- Add new language
- Code failing in production (NextJS)
- Color Scheme / Theme Not Working HOT 1
- Does this React component not support SSO feature? HOT 5
- Tree shaking - bundle size HOT 1
- A11y failures meaning my website isn't WCAG AA
- Broken link to register if the shortname is incorrect
- Document how to disable reactions
- TypeError: Super expression must either be null or a function HOT 5
- Add theme prop to switch between light and dark mode HOT 1
- No Callbacks Running
- Dark Mode (Tailwind) not working HOT 5
- May `DiscussionEmbedConfig` type need `remoteAuthS3` field?
- CommentCount.js:125 Uncaught TypeError: Cannot read properties of undefined (reading 'string')
- Uncaught Error with parseColor using OKLCH color format in Next.js HOT 4
- Error: Super expression must either be null or a function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from disqus-react.