title: Setting an state with an array variable cannot add a new property Error
body: <p>I am using Geolocation service and pushed coordinate changes in to an array variable but when I use set state it throws an error it says cannot add new property.</p>
  <p>here is my code :</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let dataarray = []
    const startTrackingFunction = async () =&gt; {
      await Geolocation.watchPosition(
        position =&gt; {
          const crd = position.coords;
  
          setPosition({
            latitude: crd.latitude,
            longitude: crd.longitude,
            latitudeDelta: LATITUDE_DELTA,
            longitudeDelta: LONGITUDE_DELTA,
          });
          dataarray.push(crd);
          setCoordinates(dataarray);
  
        },
        error =&gt; {
          console.log(error);
        },
        {
          showLocationDialog: true,
          enableHighAccuracy: true,
          timeout: 20000,
          maximumAge: 0,
          distanceFilter: 0,
        });
      setTracking(true);
    }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/W5jL6.jpg" rel="nofollow noreferrer">enter image description here</a></p>