expo-three-orbit-controls icon indicating copy to clipboard operation
expo-three-orbit-controls copied to clipboard

TypeError: Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.

Open artursahak opened this issue 3 years ago • 3 comments

const [camera, setCamera] = React.useState<Camera | null>(null); at line 20 is giving the TypeError of being a non-iterable instance. Could you suggest another way for handling the state for view's camera variable?

artursahak avatar Nov 04 '21 20:11 artursahak

const [camera, setCamera] = React.useState<Camera | null>(null); at line 20 is giving the TypeError of being a non-iterable instance. Could you suggest another way for handling the state for view's camera variable?

Same problem

Dionise avatar Mar 29 '22 13:03 Dionise

Same issue. The current App.tsx sample code does not work with the latest expo libraries.

The "non-iterable" error happens because camera is null on the first render. One workaround is to initialize it immediately and not use useState:

  const camera = new PerspectiveCamera(
    75,
    1, // initial aspect of 1
    0.1,
    1000
  );

    // in onContextCreate
    camera.aspect = width / height;

ts-web avatar Dec 03 '22 23:12 ts-web

Hi, i have the same error ERROR TypeError: Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a Symbol.iterator method.

A7640S avatar Aug 16 '24 15:08 A7640S