title: How to add multiple values to react hook without rendering the view
body: <p>I'm working on a react native project.</p>
  <p>I want to add multiple images in the useState hook without re-setting the state of the hook.</p>
  <p><strong>eg: I want to capture an image using the camera and update the hook with the file path (this is okay at the moment), then I want to capture another image through the camera and update the react hook with the previous value (need previous file path and new file path should be there).</strong></p>
  <p>problem is when I try to capture a new image and update the useState, the useState hook re-render the view, It'll delete the previous file path and stored a new file path.</p>
  <p>I'm suffering from this issue, Please help me to find a solution. Thanks in advance.</p>
  <pre><code> const tempArray = [];
      const [selectedFiles, setSelectedFiles] = useState([]);
              
      // capturing the image --------------
      const chooseFile = () =&gt; {
          const options = {
              title: 'Select an option',
              storageOptions: {
                   skipBackup: true,
                   path: 'images',
              },
          };
              
          ImagePicker.showImagePicker(options, (response) =&gt; {
          // console.log('Response = ', response);
          if (response.didCancel) {
             console.log('User cancelled image picker');
          } else if (response.error) {
             onsole.log('ImagePicker Error: ', response.error);
          } else {
          // let source = response;
          // You can also display the image using data:
              let source = {
                 uri: 'data:image/jpeg;base64,' + response.data
              };
             createImageArray(source);
       }
      });
   };
              
              const createImageArray = (imageData: string) =&gt; {
          // adding file path to temp array -&gt; to get the selected images
                      tempArray.push(imageData);
                      setImagesToHooks();
                      console.log(&quot;tempArray.length : &quot; + tempArray.length);
                  }
              
                  const setImagesToHooks = () =&gt; {
                      const imagesArray = Array.from(tempArray).map((result) =&gt; result);
                      console.log('images : ' + JSON.stringify(imagesArray));
          // adding mapped array to state hook
                      setSelectedFiles(imagesArray);
                  }
  </code></pre>