We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Getting this error on build. WebpackError: ReferenceError: window is not defined Anyone else having the same issue?
WebpackError: ReferenceError: window is not defined
The text was updated successfully, but these errors were encountered:
I have fixed it by making it clientside only Next.js Example
// pages/index.js import React from 'react'; import dynamic from 'next/dynamic'; const OBJModel = dynamic( () => import('react-3d-viewer').then((module) => module.OBJModel), { ssr: false } ); const HomePage = () => { return ( <div> {OBJModel && ( <OBJModel src="/path/to/model.obj" width={500} height={500} position={{ x: 0, y: 0, z: 0 }} /> )} </div> ); }; export default HomePage;
React Example
import React, { useRef, useEffect } from 'react'; import { OBJModel } from 'react-3d-viewer'; const ThreeJsComponent = () => { const mountRef = useRef(null); useEffect(() => { if (typeof window !== 'undefined') { mountRef.current.appendChild(document.createElement('div')); } }, []); return ( <div ref={mountRef}> {/* Render the OBJModel component */} <OBJModel src="/path/to/model.obj" width={500} height={500} position={{ x: 0, y: 0, z: 0 }} /> </div> ); }; export default ThreeJsComponent;
Sorry, something went wrong.
we can now close the issue.
No branches or pull requests
Getting this error on build.
WebpackError: ReferenceError: window is not defined
Anyone else having the same issue?
The text was updated successfully, but these errors were encountered: