-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
passing active theme name with next-themes doesn't change giscus theme upon refresh #190
Comments
Thanks for the report, I'll fix this soon. In the meantime, you can use the following workaround to fix this issue: import Giscus, { Theme } from '@giscus/react';
import { useTheme } from 'next-themes';
import { useEffect, useState } from 'react';
type GiscusCommentProps = {
category: string;
categoryId: string;
};
export default function GiscusComment({ category, categoryId }: GiscusCommentProps) {
const { theme } = useTheme();
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) return null;
return (
<Giscus
repo='<repoName>'
repoId='<repoId>'
category={category}
categoryId={categoryId}
mapping='pathname'
reactionsEnabled='0'
emitMetadata='0'
theme={theme as Theme}
/>
);
} |
I've confirmed that your workaround solved it, thanks @laymonage |
Fix released in 2.0.4. Thanks for the report! |
@markshenouda The issue is not with giscus, it's with how you use next-themes with it. The Example: https://github.com/laymonage/base/blob/main/src/components/Giscus.tsx |
Thank you so much for explaining that, I just spend too much time debugging this bug |
On the latest
@giscus/react: 2.0.3
passing the active theme name fromnext-themes 0.1.1
doesn't change the giscus theme upon refresh. For example when dark mode is toggled the giscus theme becomes dark as expected, but when you refresh the browser or reload the giscus iframe then the giscus theme turns back to light on a dark themed page.In version 1.1.2 of
@giscus/react
it worked correctly, as an example:The text was updated successfully, but these errors were encountered: