Skip to content
This repository was archived by the owner on Jun 5, 2022. It is now read-only.

Allow one Image select #59

Open
osamakhanedu opened this issue Jul 18, 2018 · 13 comments
Open

Allow one Image select #59

osamakhanedu opened this issue Jul 18, 2018 · 13 comments

Comments

@osamakhanedu
Copy link

how can config component so it allow only selection of single image currently can select multiple images

@ivnnv
Copy link
Collaborator

ivnnv commented Jul 18, 2018

you can use prop singleImage={true}.
It is there, but not showing in the documentation at the moment.

@osamakhanedu
Copy link
Author

i am setting singleImage={true} but its not working it is selecting more then one images and showing there preview. i only want to show preview of one image

@xizzat
Copy link

xizzat commented Aug 10, 2018

@osamakhanedu me too

@nerdsquirrel
Copy link

using singleImage={true} is restricting from selecting multiple images at a time. But still multiple images can be selected by one at a time.

@dmitrijBerg
Copy link

Maybe someone who worked with the Component might figure out how to implement a behaviour that only allows for a single Image to be added at a time (Just like singleImage={true} already does.) and whenever another is selected it removes the Image that's already there, only to replace it with the new one.
Since this seems more like the intended way adding a singe Image would work, I propose to make this new behaviour work with the singleImage prop.

@juusaw
Copy link
Contributor

juusaw commented Dec 11, 2018

A quick solution would be to disable the button when there's an image.

Adding the following to the <button /> element should do the trick

disabled={this.props.singleImage && this.state.files[0]}

@vsshaposhnikov
Copy link

@juusaw Where are you see the button ? Or you change the the source component code ?

@juusaw
Copy link
Contributor

juusaw commented Dec 13, 2018

That's internal to the library, yes. So an update to the library would be required.

@vsshaposhnikov
Copy link

vsshaposhnikov commented Dec 13, 2018

For fix this issue need to add
if (this.props.singleImage) { dataURLs = []; files = []; }
in onDropFile() method inside component.

@amitbravo
Copy link

none of them suggestion working,
@juusaw button is not disabling at all , even when I use disabled={true}
@vsshaposhnikov if I paste this code in onDropfile() under compiled.js or index.js in the react-native-images-upload , it does not pick a single image.

@taylorgannon
Copy link

So far my best quick fix is to add display: 'none' to the buttonStyles prop if there are 1 or more images. This way the button does not appear.

@RobertStuff
Copy link

@taylorstyers
Have you add the style directly on source code? or on your style css?

@RobertStuff
Copy link

@taylorstyers
buttonStyles only works on hard coded style. but when I put a function It doesn't work..
buttonStyles={{display: function()}} doesn't work
buttonStyles={{display: 'none'}} working

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

10 participants