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

Uppy displays error when navigating to the next tab #1243

Closed
tot98git opened this issue Jan 15, 2019 · 2 comments
Closed

Uppy displays error when navigating to the next tab #1243

tot98git opened this issue Jan 15, 2019 · 2 comments
Assignees
Labels
React React components or other React integration issues

Comments

@tot98git
Copy link

Hi,
I'm using Uppy in a react project.
I have set up Uppy file uploader in a functional component like this:

export default ({
    handleUpload, onUpload, name, props, mode
}) => {
    const uppy = new Uppy({
        autoProceed: false,
        restrictions: {
            hideUploadButton: true,
            maxFileSize: 10000000, // uppy options
            maxNumberOfFiles: props.max,
            minNumberOfFiles: 1,
            allowedFileTypes: props.allowed,
        }
    }).on('file-added', (file) => {
        onUpload(file.data, name);
    }).on('upload', () => {
        if (mode === "instant") {
            handleUpload();
        }
        uppy.setState({ files: {} });
    });
    return (
        <Dashboard // uppy dashboard component
            uppy={uppy}
            plugins={[]}
            proudlyDisplayPoweredByUppy={false}
            hideUploadButton={mode !== "instant"}
            showProgressDetails
        />
    );
};

I call this component in a MUI stepper. It's mounted in the first page only as that's the only place we need it. But when navigating from the first page to the second I get this error:
image.

I have found the fix to be to manually modify the module by navigating to node_modules/@uppy/react/lib/Dashboard.js and commenting out the following:

Dashboard.prototype.componentWillUnmount = function componentWillUnmount() {
   var uppy = this.props.uppy;

   // uppy.removePlugin(this.plugin);
 };

However manually modifying the module doesn't seem like a long term fix. Maybe the problem is in the way I mount the component. Nevertheless, I'm reporting this issue in case anyone else encounters it.
Thank you!

@arturi arturi added the React React components or other React integration issues label Jan 22, 2019
@arturi
Copy link
Contributor

arturi commented Jan 22, 2019

Hi! Could you try moving Uppy init code outside of your render method, while leaving what’s currently in return (...) in render?

Related to: #1198 (comment).

@arturi arturi self-assigned this Jan 22, 2019
@tot98git
Copy link
Author

Thank you so much! That worked. I'm closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React React components or other React integration issues
Projects
None yet
Development

No branches or pull requests

2 participants