Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload Preview not showing without updating the state manually in handle status nextjs14.1.3 #216

Open
unreal0901 opened this issue Apr 30, 2024 · 0 comments

Comments

@unreal0901
Copy link

"use client";

import dynamic from "next/dynamic";
// https://github.com/fortana-co/react-dropzone-uploader
// react-dropzone-uploader

import "react-dropzone-uploader/dist/styles.css";

import Dropzone from "react-dropzone-uploader";
import { useState } from "react";

export const DropzoneUploader = () => {
  // specify upload params and url for your files
  const [isUpdatePreview, setIsUpdatePreview] = useState(false);
  const getUploadParams = ({ meta }: any) => {
    return { url: "https://httpbin.org/post" };
  };

  // called every time a file's `status` changes
  const handleChangeStatus = ({ meta, file }: any, status: any) => {
    setIsUpdatePreview(!isUpdatePreview);
    console.log(status, meta, file);
  };

  // receives array of files that are done uploading when submit button is clicked
  const handleSubmit = (files: any) => {
    console.log(files.map((f: any) => f.meta));
  };

  return (
    <Dropzone
      getUploadParams={getUploadParams}
      onChangeStatus={handleChangeStatus}
      onSubmit={handleSubmit}
      accept="image/*,audio/*,video/*"
    />
  );
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant