title: react-native loading a list of images from gallery using hooks,
body: <p>Im using react native and hooks to make a view where i choose from taking a photo with my camera or open my cellphone gallery and chose any image i want, once i have a picture it should show the image in a list, so if i choose more than one picture it should show more than oneimage in the list.</p>
  
  <pre><code>const Seleccion = ({navigation}) =&gt; {
    const [fileList, setFileList] = useState([]);
    const state = useMemo(() =&gt; ({ fileList }), [fileList]);
  
    const onSelectedImage = useCallback((image) =&gt; {
      setFileList(fileList =&gt; {
        const newDataImg = [...fileList];
        const source = { uri: image.path };
        const item = {
          id: Date.now(),
          url: source,
          content: image.data
        };
        newDataImg.push(item);
        return newDataImg;
      });
    }, [setFileList]);
  
    const takePhotoFromCamera = useCallback(() =&gt; {
      ImagePicker.openCamera({
        width: 300,
        height: 400,
      }).then(image =&gt; {
        onSelectedImage(image);
        console.log(image);
      });
    }, [onSelectedImage]);
  
    const choosePhotoFromLibrary = useCallback(() =&gt; {
      ImagePicker.openPicker({
        width: 300,
        height: 400,
      }).then(image =&gt; {
        onSelectedImage(image);
        console.log(image);
      });
    }, [onSelectedImage]);
  
    const renderItem = useCallback(({ item, index }) =&gt; {
      return (
        &lt;View&gt;
          &lt;Image source={item.url} style={styles.itemImage} /&gt;
        &lt;/View&gt;
      );
    }, []);
  
    return (
      &lt;View style={styles.container}&gt;
        &lt;FlatList
          data={fileList}
          keyExtractor={(item, index) =&gt; index.toString()}
          renderItem={renderItem}
          extraData={state}
        /&gt;
  
        &lt;TouchableOpacity style={styles.viewData} onPress={takePhotoFromCamera}&gt;
          &lt;Text&gt;Foto&lt;/Text&gt;
        &lt;/TouchableOpacity&gt;
  
        &lt;TouchableOpacity style={styles.viewData} onPress={choosePhotoFromLibrary}&gt;
          &lt;Text&gt;galeria&lt;/Text&gt;
        &lt;/TouchableOpacity&gt;
      &lt;/View&gt;
    );
  }
  </code></pre>