Skip to content
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

common: update and simplify code #1987

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions react/src/lib/Giscus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,30 @@ export default function Giscus({

useEffect(() => {
if (mounted) return;
import('giscus');
setMounted(true);
import('giscus').then(() => setMounted(true));
}, []);

if (!mounted) return null;

return (
<giscus-widget
id={id}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but this wraps the component in a fragment unnecessarily. I'd much prefer the old explicit return null.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I revert to old explicit return null in 7286aeb.

host={host}
repo={repo}
repoid={repoId}
category={category}
categoryid={categoryId}
mapping={mapping}
term={term}
strict={strict}
reactionsenabled={reactionsEnabled}
emitmetadata={emitMetadata}
inputposition={inputPosition}
theme={theme}
lang={lang}
loading={loading}
/>
<>
{mounted && (
<giscus-widget
id={id}
host={host}
repo={repo}
repoid={repoId}
category={category}
categoryid={categoryId}
mapping={mapping}
term={term}
strict={strict}
reactionsenabled={reactionsEnabled}
emitmetadata={emitMetadata}
inputposition={inputPosition}
theme={theme}
lang={lang}
loading={loading}
/>
)}
</>
);
}