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

MImageBody doesn't check whether it is still mounted before setState #2964

Closed
JaniM opened this issue Jan 17, 2017 · 0 comments · Fixed by matrix-org/matrix-react-sdk#3294
Closed
Assignees
Labels
P3 T-Defect T-Task Tasks for the team like planning Z-Community-PR Issue is solved by a community member's PR

Comments

@JaniM
Copy link
Contributor

JaniM commented Jan 17, 2017

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the MImageBody component

Happens in componentDidMount's promse.

            thumbnailPromise.then((thumbnailUrl) => {
                return decryptFile(content.file).then(function(blob) {
                    decryptedBlob = blob;
                    return readBlobAsDataUri(blob);
                }).then((contentUrl) => {
                    this.setState({ // <----
                        decryptedUrl: contentUrl,
                        decryptedThumbnailUrl: thumbnailUrl,
                        decryptedBlob: decryptedBlob,
                    });
                    this.props.onWidgetLoad();
                });
            }).catch((err) => {
                console.warn("Unable to decrypt attachment: ", err);
                // Set a placeholder image when we can't decrypt the image.
                this.setState({
                    error: err,
                });
            }).done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 T-Defect T-Task Tasks for the team like planning Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants