Johann-S / bs-custom-file-input

A little plugin for Bootstrap 4 custom file input
https://bs-custom-file-input.netlify.com/
MIT License
210 stars 39 forks source link

When to call bsCustomFileInput.init() in a react app (when using in a Modal dialog)? #81

Open boatcoder opened 4 years ago

boatcoder commented 4 years ago

I've tried calling it in componentDidMount() of the dialog, (like the example), but It is not working. I've had to move it to the onChange for the file input so that it actually updates the screen. I'm pretty sure the problem is that my File.Input field is in the modal rather than on the base part of the page, noting this here for others that have this problem. Would be really nice if this could somehow be integrated into the react-bootstrap so that these kinds of workaround aren't needed.

The code in the onChange handler looks like this:

    if (this.customFileInit) {
      bsCustomFileInput.destroy();
    }
    bsCustomFileInput.init();
    this.customFileInit = true;