Closed akhan118 closed 5 years ago
UP similar condition
I ended up putting the viewer in a component of it's own and pass the images as a state. it worked for me with no issues.
Hi,
Image data has uri key not url You have to add url key in your image data.
Update your image data as bellow.
var url = { url: data.uri }
var newImageData = { ...data, ...url }
<ImageViewer imageUrls={[ { url: '', props: { source: { uri: data.uri, }, }, }, ]} />
Thanks !
Hi all,
I'm using react native camera and the takePicture function returns a promise.
the promise has the usual data of an image object , {uri://file}
I would like to take that 'uri' and set it as state so I can pass it to react-native- viewer .
The problem is that I can't set it .
because the require() function gives an error.
example
it gives an error because the image has to be available when compile. and data.uri is not available when compile.
Here is a full example of the promise and image
causes this error
Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(src/screens/CameraModalScreen.js: src/screens/CameraModalScreen.js:Invalid call at line 140: require(data.uri) (null))
38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.213 RCTCxxBridge.mm:414 _ZL36attemptAsynchronousLoadOfBundleAtURLP5NSURLU13block_pointerFvP18RCTLoadingProgressEU13block_pointerFvP7NSErrorP9RCTSourceE_block_invoke.118 80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke -[RCTMultipartStreamReader emitChunk:headers:callback:done:] -[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:] -[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:] __88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK -[NSBlockOperation main] -[NSOperationInternal _start:] __NSOQSchedule_f _dispatch_call_block_and_release _dispatch_client_callout _dispatch_continuation_pop _dispatch_async_redirect_invoke _dispatch_root_queue_drain _dispatch_worker_thread2 _pthread_wqthread start_wqthread
How can I pass a local image that I captured from camera to the viewer ?
Thanks in advance.