Skip to content

Commit

Permalink
inclued code blocks in html (codemirror renders after load)
Browse files Browse the repository at this point in the history
  • Loading branch information
phartenfeller committed Feb 4, 2024
1 parent f03c97b commit 38a1e9f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/blog/Codemirror.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ const Codemirror = ({ lang, code }) => {
fontSize: 14,
});

return <div className="max-w-[90vw]" ref={codeRef} />;
const [isMounted, setIsMounted] = React.useState(false);
React.useEffect(() => {
setIsMounted(true);
}, []);

return (
<div className="max-w-[90vw]" ref={codeRef}>
{!isMounted && <code>{code}</code>}
</div>
);
};

Codemirror.propTypes = {
Expand Down

0 comments on commit 38a1e9f

Please sign in to comment.