Module Image-BsReactNative
module type ImageComponent = { ... };module CreateComponent: (Impl: BsReactNative.View.Impl) => ImageComponent;include ImageComponent;
type _imageURISource;Example of use
Imagecomponent https://facebook.github.io/react-native/docs/image requires thesourceprop, here is the example usage. Note that you also need to specify the width and height, this can be done viaimageURISourcenamed arguments, or viastyleprop that is passed toImagecomponentsource from URI
let component = ReasonReact.statelessComponent("MyComponent"); let make = _children => { ...component, render: _self => <Image source=( `URI( Image.( imageURISource( ~uri="https://bit.ly/2ya4e2o", ~width=Pt(320.), ~height=Pt(480.), (), ) ), ) ) />, };source from a file path
One thing to remember here is that the path is relative to the compiled code.
let component = ReasonReact.statelessComponent("MyComponent"); let make = _children => { ...component, render: _self => <Image style=Style.(style([width(Pt(320.)), height(Pt(480.))])) source=(`Required(Packager.require("./assets/panamera.png"))) />, };Props
onError
onError: Event.error => unit=?onLayout
onLayout: RNEvent.NativeLayoutEvent.t => unit=?Reference
RNEvent.NativeLayoutEventonLoad
onLoad: unit => unit=?onLoadEnd
onLoadEnd: unit => unit=?onLoadStart
onLoadStart: unit => unit=?resizeMode
resizeMode: [< | `center | `contain | `cover | `repeat | `stretch ]=?source
source: imageSourcelet _imageURISource: ( ~uri: string, ~bundle: string=?, ~method: string=?, ~headers: Js.t('a)=?, ~body: string=?, ~cache: [ | `default | `reload | `forceCache | `onlyIfCached]=?, ~scale: float=?, ~width: option(float)=?, ~height: option(float)=?, unit ) => _imageURISource;type pt_only = | Pt(float); type imageURISource; let imageURISource: ( ~uri: string, ~bundle: string=?, ~method: string=?, ~headers: Js.t('a)=?, ~body: string=?, ~cache: [ | `default | `reload | `forceCache | `onlyIfCached]=?, ~scale: float=?, ~width: Style.pt_only=?, ~height: Style.pt_only=?, unit ) => _imageURISource;style
style: Style.t=?testID
testID: string=?resizeMethod
resizeMethod: [< | `auto | `resize | `scale ]=?accessibilityLabel
accessibilityLabel: string=?blurRadius
blurRadius: float=?capInsets
capInsets: Types.insets=?reference:
type insets = { . "left": int, "right": int, "top": int, "bottom": int, };defaultSource
defaultSource: defaultSource=?type defaultSource = [ | `URI(_defaultURISource) | `Required(Packager.required) ];let _defaultURISource: ( ~uri: string, ~scale: float=?, ~width: option(float)=?, ~height: option(float)=?, unit ) => _defaultURISource;let defaultURISource: ( ~uri: string, ~scale: float=?, ~width: Style.pt_only=?, ~height: Style.pt_only=?, unit ) => _defaultURISource;type pt_only = | Pt(float);onPartialLoad
onPartialLoad: unit => unit=?onProgress
onProgress: Event.progress => unit=?API reference
let _imageURISource: uri:string => ?bundle:string => ?method:string => ?headers:Js.t('a) => ?body:string => ?cache:[ `default | `reload | `forceCache | `onlyIfCached ] => ?scale:float => ?width:option(float) => ?height:option(float) => unit => _imageURISource;
let imageURISource: uri:string => ?bundle:string => ?method:string => ?headers:Js.t('a) => ?body:string => ?cache:[ `default | `reload | `forceCache | `onlyIfCached ] => ?scale:float => ?width:BsReactNative.Style.pt_only => ?height:BsReactNative.Style.pt_only => unit => _imageURISource;
type imageSource=[|`URI(_imageURISource)|`Required(BsReactNative.Packager.required)|`Multiple(list(_imageURISource))];type _defaultURISource;
let _defaultURISource: uri:string => ?scale:float => ?width:option(float) => ?height:option(float) => unit => _defaultURISource;
let defaultURISource: uri:string => ?scale:float => ?width:BsReactNative.Style.pt_only => ?height:BsReactNative.Style.pt_only => unit => _defaultURISource;
type defaultSource=[|`URI(_defaultURISource)|`Required(BsReactNative.Packager.required)];
module Event: { ... };let make: ?onError:(Event.error => unit) => ?onLayout:(BsReactNative.RNEvent.NativeLayoutEvent.t => unit) => ?onLoad:(unit => unit) => ?onLoadEnd:(unit => unit) => ?onLoadStart:(unit => unit) => ?resizeMode:[< `center | `contain | `cover | `repeat | `stretch ] => source:imageSource => ?style:BsReactNative.Style.t => ?testID:string => ?resizeMethod:[< `auto | `resize | `scale ] => ?accessibilityLabel:string => ?accessible:bool => ?blurRadius:float => ?capInsets:BsReactNative.Types.insets => ?defaultSource:defaultSource => ?onPartialLoad:(unit => unit) => ?onProgress:(Event.progress => unit) => array(ReasonReact.reactElement) => ReasonReact.component(ReasonReact.stateless, ReasonReact.noRetainedProps, unit);
type asset= Js.t({. uri: string, width: int, height: int, });type assetSource=[|`URI(_imageURISource)|`Required(BsReactNative.Packager.required)];
let resolveAssetSource: assetSource => asset;