From beace3e476058aab888abc012dda839b311ea88e Mon Sep 17 00:00:00 2001 From: "A. Bryant" Date: Sun, 20 Aug 2023 00:26:14 -0600 Subject: [PATCH] dynamic --- src/components/CrtSwitch.tsx | 6 +++++- src/components/Dots.tsx | 6 +++++- src/components/LanguageSwitch.tsx | 5 ++++- src/components/Terminal.tsx | 3 +++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/CrtSwitch.tsx b/src/components/CrtSwitch.tsx index 5f0c88f..3622beb 100644 --- a/src/components/CrtSwitch.tsx +++ b/src/components/CrtSwitch.tsx @@ -2,6 +2,8 @@ import React, { useState } from 'react'; import styles from '../css/switch.module.css'; import { vt323 } from '../fonts/fonts'; import { useLanguageContext } from '../app/context/language'; +import dynamic from "next/dynamic"; + interface CrtProps { changeState: (newValue: boolean) => void; @@ -46,4 +48,6 @@ const CrtSwtich: React.FC = ({ changeState }) => { ); }; -export default CrtSwtich; \ No newline at end of file +export default dynamic (() => Promise.resolve(CrtSwtich), {ssr: false}) + +/* export default CrtSwtich; */ \ No newline at end of file diff --git a/src/components/Dots.tsx b/src/components/Dots.tsx index ecfa5d9..33912cf 100644 --- a/src/components/Dots.tsx +++ b/src/components/Dots.tsx @@ -96,7 +96,11 @@ const Dots = () => { } } - new p5(sketch, sketchRef.current as HTMLElement); + + if (typeof window !== 'undefined') { + const p5 = require('p5'); + new p5(sketch, sketchRef.current); + } }, []); return
; diff --git a/src/components/LanguageSwitch.tsx b/src/components/LanguageSwitch.tsx index 813ceac..34870fe 100644 --- a/src/components/LanguageSwitch.tsx +++ b/src/components/LanguageSwitch.tsx @@ -1,6 +1,7 @@ import styles from '../css/switch.module.css' import { vt323 } from '../fonts/fonts'; import { useLanguageContext } from '../app/context/language'; +import dynamic from "next/dynamic"; const LanguageSwitch = () => { const {language, setLanguage} = useLanguageContext(); @@ -56,4 +57,6 @@ const LanguageSwitch = () => { ) }; -export default LanguageSwitch; \ No newline at end of file +export default dynamic (() => Promise.resolve(LanguageSwitch), {ssr: false}) + +/* export default LanguageSwitch; */ \ No newline at end of file diff --git a/src/components/Terminal.tsx b/src/components/Terminal.tsx index 5623cff..b054092 100644 --- a/src/components/Terminal.tsx +++ b/src/components/Terminal.tsx @@ -3,6 +3,7 @@ import { useState, useRef, useEffect } from 'react'; import { useLanguageContext } from '../app/context/language'; import styles from '../css/terminal.module.css' import { vt323 } from '../fonts/fonts' +/* import dynamic from "next/dynamic"; */ const Terminal = () => { @@ -331,4 +332,6 @@ const Terminal = () => { ) }; +/* export default dynamic (() => Promise.resolve(Terminal), {ssr: false}) */ + export default Terminal \ No newline at end of file