Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React Native Image does not accept url and styles from stylesheet

$
0
0

I need to display an image from the backend in my app, image is a string hosted on AWS S3, and its 100% there when the image is rendered, according to the docs I should be able to display the image by passing the URL to the object of shape

{ uri: string }

https://reactnative.dev/docs/image#imagesource

but when I replace the path to the local file with the URI object I get an error saying that

components/MapComponents/SpotInfoOnMap.tsx: components/MapComponents/SpotInfoOnMap.tsx:Invalid call at line 35: require({  uri: photoUrl})ABI45_0_0RCTFatal__37-[ABI45_0_0RCTCxxBridge handleError:]_block_invoke_dispatch_call_block_and_release_dispatch_client_callout_dispatch_main_queue_callback_4CF__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE____CFRunLoopRunCFRunLoopRunSpecificGSEventRunModal-[UIApplication _run]UIApplicationMainmainstart_sim0x00x0

and also it does not accept my stylesheet styles saying that

  Type 'ViewStyle | TextStyle | ImageStyle' is not assignable to type 'StyleProp<ImageStyle>'.      Type 'ViewStyle' is not assignable to type 'StyleProp<ImageStyle>'.        Type 'ViewStyle' is not assignable to type 'ImageStyle'.          Types of property 'overflow' are incompatible.            Type '"visible" | "hidden" | "scroll" | undefined' is not assignable to type '"visible" | "hidden" | undefined'.              Type '"scroll"' is not assignable to type '"visible" | "hidden" | undefined'.  Overload 2 of 2, '(props: ImageProps, context: any): Image', gave the following error.    Type 'ViewStyle | TextStyle | ImageStyle' is not assignable to type 'StyleProp<ImageStyle>'.ts(2769)

although I don't declare any overflow styles in this declaration according to the docs IO also should be passing width and height when I pass a URI to the image but when I do that I get an error saying that

Property 'width' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Image> & Readonly<ImageProps>'.ts(2769)

Please shed some light on this problem, I'm lostThanks


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>