Cannot read properties of undefined (reading 'x') when Seting angle to the camera

I am using setAzimuthalAngle and setPolarAngle to set the angle of the camera. I already have used this and I know how it should be written. But the problem I have now which I dont understand is undefined x.

Note: The problem doesnt occure in If I hardcode these values it will display the same error.

 const radiusAngle = (deg) => (Math.PI / 180) * deg;

  useEffect(() => {
    if (orbitRef.current) {
      orbitRef.current.setAzimuthalAngle(radiusAngle(; !== null && 
  }, [,]);