Closed ndao closed 8 years ago
@ndao. I will prepare a commit for preserving the state by passing an array of selected image as a props to the component and setting this props as the default value of selected state.
@ndao. Now you can pass a selected array as a props to the component, as the example here https://github.com/jeanpan/react-native-camera-roll-picker/blob/master/Example/index.ios.js#L50 to preserve the selected state. Let me know if this solve your problem.
@jeanpan wow that was fast! thanks so much!
Question: in the latest version, the callback
now returns an array of Objects
whereas before it was returning an array of string
. As they're objects now, this won't return the right index https://github.com/jeanpan/react-native-camera-roll-picker/blob/master/index.js#L159
to satisfy the selected state.
it is breaking for me. thoughts?
@ndao. Yes, before the callback
returns an array of string ( image uri ) but now it returns an array of Objects
( image object ). The indexOf
works fine for me. Is your selected state a object array or a string array ? Could you please provide me your code so I can help you to fix the problem ?
@jeanpan, i am basically using Redux to store the objects that returned from callback
and pass it back again to CameraRollPicker component
Below is what the array of objects looks like
like so
<View
style={{flex: 1, flexDirection: 'column'}}>
<CameraRollPicker
groupTypes='All'
maximum={15}
assetType='All'
imagesPerRow={3}
imageMargin={5}
selectedMarker={<Marker />}
selected={selected}
callback={this.props.attachPhotos} />
</View>
it also looks like the Camera component adds the selected
array that i am passing in to its state (but not showing those images are selected). it then returns all the newly selected items PLUS the selected array items that was passed in.
@ndao It seems there is something wrong with selected state. I will fix it asap. Thanks for the comments.
@ndao I fixed the problem in the latest version ( 1.1.5 ). Please check it and let me know if there is any problem. Thanks !
looks like 1.1.5 fixed it! thanks so much!
@jeanpan, there's another issue. The selected state is kept despite new selected
props being passed in. perhaps it needs a componentWillReceiveProps
to update state.
@ndao ok. Will fix it asap. Thanks!
@ndao Fixed at the latest version 1.1.6. Please let me know if there is any question. Thanks ! https://github.com/jeanpan/react-native-camera-roll-picker/commit/16991b522c53b50b567cb47b8c482dd8472358b0
thanks @jeanpan, fyi there are some warnings with the SGListView stuff
@ndao Thanks for the fyi. I will created another issue to track the warnings of SGListView.
Hi, after selecting some images, I would like to preserve the state so when I go back to it they're already selected. Is there a way to do that currently?
Thanks!