vutoan266 / react-images-uploading

The simple images uploader applied Render Props pattern that allows you to fully control UI component and behaviors.
https://github.com/vutoan266/react-images-uploading
MIT License
320 stars 52 forks source link

Images are not getting pushed to state #145

Closed faisol-zufaa closed 1 year ago

faisol-zufaa commented 1 year ago

I followed the guideline to setup react-images-uploading. Below is the code where the problem occurs -

const ImageAdd = ( { getImg } ) => {

const [ images, setImages ] = useState( [] );
const maxNumber = 1;
const onChange = ( imageList, addUpdateIndex ) => {
    // data for submit
    console.log( imageList, addUpdateIndex );  // here it shows the image info
    setImages(imageList);
    console.log(images);  // here it shows empty array 
    };
  }

SS added.

images-uploads

Also I wanted to pass this array to a parent component , from where getImg function comes from. Due to images state being empty it sends undefined . And I have no idea how to access imageList array.

faisol-zufaa commented 1 year ago

Well it's working now. Do not know how.