Closed arshdeepsingh2267 closed 1 year ago
I also tried forwardRef()
thing as there is an issue when we dynamically import any component which in our case is <Globe />
but no luck. My reference : https://github.com/vercel/next.js/issues/4957#issuecomment-413841689
@arshdeepsingh2267 I think this is more a question about using next.js dynamic imports with refs than this module in particular. So, I can't give you much useful advice on that. A next.js forum would be more appropriate I think.
To me it looks odd if you're importing the module dynamically inside your component, because that will run at every rerender, but I can't say with certainty if that's the root cause or not.
@arshdeepsingh2267 I think this is more a question about using next.js dynamic imports with refs than this module in particular. So, I can't give you much useful advice on that. A next.js forum would be more appropriate I think.
To me it looks odd if you're importing the module dynamically inside your component, because that will run at every rerender, but I can't say with certainty if that's the root cause or not.
Initially I imported <Globe/>
normally. Then I started receiving "window is not defined". Then only I tried importing it dynamically.
Yes, but why to import it inside the component?
The issue got resolved
@arshdeepsingh2267 How did you solve it? I am facing the same issue right now
useRef not working for react-globe.gl in Next js react-globe.gl is working fine with Next js when . Only reason to provide reference is to use features like
<Globe />
imported dynamically (or using Suspense and lazy() ). Only issue is that I am unable to give reference toautoRotate
and to setenableZoom
as false. Tried it with keepingglobeEl.current.controls().autoRotate = true;
insideuseEffect()
and outside as well. Also, usedsetInterval()
just to see if maybe later on<Globe />
is picking up the ref or not. But, no luck. Here is how I am trying to achieve it.Error popping up as as its reference.
Please let me know if there is ay other way to achieve what I want to, or is there any other issue. Thanks!
TypeError: globeEl.current.controls is not a function
. Obviously that would occur as globeEl never gets to