filestack / filestack-react

Official React component for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://www.filestack.com
MIT License
164 stars 40 forks source link

Once closed it cannot be reopened #127

Open haris316 opened 2 years ago

haris316 commented 2 years ago

Capture What I am trying to do is display a picker overlay on a button click. Once the Overlay appears and a user mistakenly closes it, there is no option to re-render it.

I have already tried onClose but it does not matter if my local variable is set to false. The component does not appear.

Any help would be appreciated..

peterjhart commented 1 year ago

import { PickerOverlay } from 'filestack-react';

function MyComponent(): JSX.Element {
  const [isOpen, setIsOpen] = setState<boolean>(false);

  const pickerOptions = {
    onClose,
  };

  function onClose() {
    setIsOpen(false);
  }

  function open() {
    setIsOpen(true);
  }

  return (
    <>
      { isOpen && (
        <div style="position:absolute">
          <PickerOverlay apiKey={MY_KEY} pickerOptions={pickerOptions} />
        </div>
      )}
      <button onClick={open}>Upload</open>
    </>
  );
}
jared-christensen commented 7 months ago

Wish this was an example in the readme.