Closed BernardoOlisan closed 11 months ago
@BernardoOlisan if you do
import ForceGraph3D from 'react-force-graph-3d'
it bypasses the aframe import, which might fix your issue.
Yes, I got the window is not defined error
, but I solved it by dynamic import. Thanks :)
I have got the same issue
I have same issue and solved by dynamic import
https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading
// src/components/force-graph.tsx
"use client";
import React from "react";
import { ForceGraph2D } from "react-force-graph";
export default function ForceGraph() {
return <ForceGraph2D />;
}
// src/app/page.tsx
import dynamic from "next/dynamic";
const ForceGraph = dynamic(
() => import("../components/force-graph"),
{
ssr: false,
loading: () => <p>Loading...</p>,
}
);
export default async function Page() {
return <ForceGraph />;
}
Describe the bug Using ForceGraph3D in Nextjs app router I'm getting this error:
Expected behavior Everything works perfect, but this error is making the website unable to deployed
Additional context I'm importing it like this:
import { ForceGraph3D } from 'react-force-graph';
And I'm using"use client";