use runInAction in getPhotos model
parent
3b899bfc66
commit
1f16c75121
|
@ -1,5 +1,5 @@
|
||||||
import {PhotoIdentifier} from './../../../node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll'
|
import {PhotoIdentifier} from './../../../node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll'
|
||||||
import {makeAutoObservable} from 'mobx'
|
import {makeAutoObservable, runInAction} from 'mobx'
|
||||||
import {CameraRoll} from '@react-native-camera-roll/camera-roll'
|
import {CameraRoll} from '@react-native-camera-roll/camera-roll'
|
||||||
import {RootStoreModel} from './root-store'
|
import {RootStoreModel} from './root-store'
|
||||||
|
|
||||||
|
@ -18,8 +18,10 @@ export class UserLocalPhotosModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _getPhotos() {
|
private async _getPhotos() {
|
||||||
|
runInAction(() => {
|
||||||
CameraRoll.getPhotos({first: 20}).then(r => {
|
CameraRoll.getPhotos({first: 20}).then(r => {
|
||||||
this.photos = r.edges
|
this.photos = r.edges
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,9 @@ import React from 'react'
|
||||||
import {Image, StyleSheet, TouchableOpacity, ScrollView} from 'react-native'
|
import {Image, StyleSheet, TouchableOpacity, ScrollView} from 'react-native'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {colors} from '../../lib/styles'
|
import {colors} from '../../lib/styles'
|
||||||
import {
|
import {openPicker, openCamera} from 'react-native-image-crop-picker'
|
||||||
openPicker,
|
|
||||||
openCamera,
|
|
||||||
ImageOrVideo,
|
|
||||||
} from 'react-native-image-crop-picker'
|
|
||||||
import {observer} from 'mobx-react-lite'
|
|
||||||
|
|
||||||
export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({
|
export const PhotoCarouselPicker = ({
|
||||||
selectedPhotos,
|
selectedPhotos,
|
||||||
setSelectedPhotos,
|
setSelectedPhotos,
|
||||||
localPhotos,
|
localPhotos,
|
||||||
|
@ -17,7 +12,7 @@ export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({
|
||||||
selectedPhotos: string[]
|
selectedPhotos: string[]
|
||||||
setSelectedPhotos: React.Dispatch<React.SetStateAction<string[]>>
|
setSelectedPhotos: React.Dispatch<React.SetStateAction<string[]>>
|
||||||
localPhotos: any
|
localPhotos: any
|
||||||
}) {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<ScrollView
|
<ScrollView
|
||||||
horizontal
|
horizontal
|
||||||
|
@ -65,7 +60,7 @@ export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
photosContainer: {
|
photosContainer: {
|
||||||
|
|
Loading…
Reference in New Issue