Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sshh12 committed Dec 29, 2024
1 parent 4e4c4b1 commit ca8b527
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion images/p5/page.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
'use client';

import { useEffect } from 'react';

export default function Home() {
return <></>;
useEffect(() => {
// Only run p5 initialization on the client side
if (typeof window !== 'undefined') {
new window.p5();
}

// Cleanup function
return () => {
if (typeof window !== 'undefined' && window.p5) {
// Remove the canvas when component unmounts
document.querySelector('canvas')?.remove();
}
};
}, []); // Empty dependency array means this runs once on mount

return <main>{/* p5.js will create and inject the canvas here */}</main>;
}

0 comments on commit ca8b527

Please sign in to comment.