How to clear thumbnails from a FineUploader Gallery dropzone - reactjs

I'm using react-fine-uploader in a project that allows users to send files to other users. I have auto-upload disabled and I'm using the Gallery component with thumbnails. Once a user has selected the files he wants to send he clicks a Send button which calls uploadStoredFiles().
Once all the files have been uploaded and a success message was displayed I want to clear the dropzone so the user can start over and send more files somewhere else.
I can't figure out how to do that. FineUploader has a reset() method that seems to reset the internal state but the thumbnails remain in the dropzone. They are rendered as <li>s in a <ul> so I could just delete those from the DOM but this being a react app that seems wrong.
Is there a proper way to do this?

this should work even out of scope:
Dropzone.forElement("#idOfDropzone").removeAllFiles(true);

Related

What is the correct way to control when/if to show tooltip in mobile app using react native?

I am writing a mobile app and when the user sees some screens of the app for the first time, I would like to show a tooltip, explaining some of the functionality.
For instance, the user navigates to the profile page, and I show a tooltip on the add icon, saying something like "you can add a photo here".
Obviously I dont want to show this tooltip every time the user navigates to the profile page, so what is the correct way of doing so? Is it via redux? Keeping some state like "tooltipWasShown"?
Or should I write a custom hook? Something which checks if the tooltip was shown? (this should happen again via redux I guess)
I dont think it is a unique problem, but I couldn't find any blog posts/examples of what is the way to implement it. Any suggestions are welcome!
You will need to use Async Storage for the save data about tutorial, if user reload app redux will be empty. Or will add isFirstEnter field to user in DB and then check this field

What kind of component I should use to inform a user that an action has been completed successfully?

I have an app where the user can download a photo. After downloading it, I want to display a small message saying "Download successful". Initially I wanted to show Modal from https://reactnative.dev/docs/modal but then I wanted this info to disappear either in 5 sec, or if the user taps outside of the modal. So I thought I should wrap my Modal inside an Animated component https://reactnative.dev/docs/animations
Am I on the right track? Is this the way to show a user friendly message - wrapping modal inside animated. Or there is another component which I can use?
I think it will be better if you use SnackBar for such purposes.
You can use any snackbar library in your project. Your wrap it around with your project, Then whenever you need to throw information message or error message you just called the hook for that snackbar. Also it will automatically disappear after showing the message. you won't need to take care of seconds.
notistack package : https://www.npmjs.com/package/notistack
You can also checkout the Material UI Alerts.

Adding the new images loaded through ajax to opened lightbox pop-up

i am facing a issue.
I have created a images gallery in which the 18 images are showing by default and if user scroll down to the end of page then more images are adding to the gallery through ajax.
Now suppose when user have 18 images and he opens a lightbox then the opend lightbox has 18 images that he can navigate back and forth.
Now if user scroll the page to end the new images are added to the page and i want to add those images to theopened lightbox.
Please suggest a way to acheive this.
Thanks in advance.
Background
When the user clicks an image, the Lightbox script's start() method is called. This will compile the list of images to show, either a single one, or a set if data-lightbox is specified, by going through the page. These are stored in a an array called album on the lightbox object.
If you dynamically load images, then the user click an image to open Lightbox, things should work as expected, as the compilation of images happens on open.
Solution
In your scenario, the Lightbox is already open, and I'm assuming you have a set of images being browsed. You want to let the user continue scrolling while the Lightbox is open and this scrolling will dynamically load more images onto the page that are part of this set.
There is no documented way of doing this. But, you can fix your issue by digging into the internals pretty easily. This is normally not recommended, but no major changes to the Lightbox2 API are expected, so this should be safe (no guarantees though).
On scroll, once new images are loaded, add them to the Lightbox object's album property manually. Then call updateDetails() to refresh the UI.
lightbox.album.push({
link: 'fruit-roll-ups.jpg'
});
lightbox.updateDetails();

Push modal box ontocurrent page with reactjs

I'm making various asynchronous http calls in my reactjs app. Errors from the server are streamlined and I would like to show an error dialog box in react regardless of the current page. I'm currently using the alert but I really would like a styled modal error box.
How do I detect the current page and inject the modal box and display it?
Thanks!
I think you should create the dialog dynamically. It means that you will create and mount the Dialog component right after the error appears. You can refer this approach from ant.design team. https://github.com/ant-design/ant-design/blob/master/components/modal/confirm.tsx

How should I use route&view

Background:
I am using backbone.js & Twitter Bootstrap in my client-end page.
On clicking the logout button on header, a confirmation dialog should open.
The question is that
should I use router such as /logout to change to logoutView ?
If click No in the dialog, how could I show the main content with data before the dialog is opened.
Thanks!
Yes, you can use a router and you should.
First thing to know, is you have to render application's layout before dispatching any route, because the layout is rendered and needed for every action, so it's independant, right ?
Second you create a "logout" route in your router and give it the "#logout" hash, then in your "logout" action you open the modal.
Don't use router for such thing. Just fire the modal directly because:
On changing the router, you are gonna push that to the History. Hitting the browser's back button shouldn't really open a modal window.
URLs should be crafted in a way to be bookmarked. You don't want a URL that would open a popup or a modal window!
It's much simpler just to start the modal than to create a variable to hold the previous view and to fall back to it when clicking No
I have build client-side apps using different MVC frameworks like AngularJS and Backbone.js. Every time I faced the same situation you are talking about and found that the easiest and most accurate way is to just show the modal.
UPDATE
Please watch this. This is Jeremy Ashkenas the author of backbone.js stating exactly your situation about how should URLs be used and weather if they should be used to open a pop up or not.

Resources