How to handle image with formik and base64 in react js?

const [postImage, setPostImage] = React.useState({

myFile: "",

images: ''

});

const convertToBase64 = (file) => {

return new Promise((resolve, reject) => {

  const fileReader = new FileReader();

  fileReader.readAsDataURL(file);

  fileReader.onload = () => {

    resolve(fileReader.result);

  };

  fileReader.onerror = (error) => {

    reject(error);

  };

});

};

const handleFileUpload = async (e) => {

const file = e.target.files[0];

const base64 = await convertToBase64(file);

setPostImage({ ...postImage, myFile: base64, images: base64 });

};

and my html tags is
<input

                      type="file"

                      className="form-control"

                      name="image"

                      accept=".jpeg, .png, .jpg"

                      onChange={handleFileUploads}

                    />