Skip to content

Cloudinary Image disappears in Edit #759

Answered by moonwave99
shrocket asked this question in Web
Discussion options

You must be logged in to vote

Quick guess: you are not uploading a new image on subsequent edits, this leading to send an image object without meaningful information, overwriting the existing image.

Possible solution: on the edit field, hide the file input field by default via state, and display just if the user wants to upload a new picture - mark it as required so they cannot leave it blank:

import { useState } from 'react';

function ServiceForm({ service = {}, onSubmit }) {
  const [showFileInput, setShowFileInput] = useState(!service._id);

  ...

  return (
    <form onSubmit={...}>
      ...
      {showFileInput ? (
        <div className="image-uploader">
          <label>
            Image
            <input n…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shrocket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants