Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Thumbnail doesn't change when provided id changes #143

Open
axelvdw opened this issue Sep 4, 2017 · 6 comments
Open

Thumbnail doesn't change when provided id changes #143

axelvdw opened this issue Sep 4, 2017 · 6 comments

Comments

@axelvdw
Copy link

axelvdw commented Sep 4, 2017

I'm using the separate components of the react-fine-uploader package to build my desired behavior.
I use the component to display a large Thumbnail of a selected image:

<Thumbnail id={this.state.selectedImage} uploader={uploader} maxSize={250} />

The state gets updated when the user clicks on a smaller version of the thumbnail, so the component re-renders. However, the displayed large thumbnail stays the same even when this.state.selectedImage changes.

@charlesswanson
Copy link

I have this problem with the FileSize component. For FileSize, the problem is that it only rerenders when the size state is changed. However, the size state is only set once in the constructor. I hacked around this by giving giving my FileSize component a prop: key={`FileSize${id}`} . That way, an entire new FileSize component is constructed when the id changes. It's not ideal, but maybe that'll work for the Thumbnail too.

@rnicholus
Copy link
Member

why would a file's size ever change? that seems very odd, and I've never personally run into this before

@rnicholus
Copy link
Member

...unless you were referring to images that are scaled by Fine Uploader just before they are uploaded. If that is the case, it would have been helpful to mention.

@rnicholus
Copy link
Member

If you want to fix the thumbnail issue you are having, a pull request that redraws in componentWillReceiveProps when the id changes should probably do it.

@charlesswanson
Copy link

why would a file's size ever change?

The size of a file doesn't change, but the file id does. I'm using the FileInput component to allow the user to select one file. I'm using the statusChange callback to detect when a new file id is submitted. When this occurs, I call fineUploader.methods.cancel(oldId). Then, I rerender the FileInput with the new id.

@rnicholus
Copy link
Member

My above suggestion should fix this too then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants