0.0.7 • Published 4 years ago

react-native-uri-box v0.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

react-native-uri-box

An extendible React <Component/> which will attempt to render source content consistently, based on the MIME type.

🚀 Getting Started

Using npm:

yarn add react-native-uri-box

Using yarn:

yarn add react-native-uri-box

✍️ Example

Just use this as a drop-in component for your remote content:

import UriBox, { LookUpTable } from 'react-native-uri-box';
import Video from 'react-native-video';

const App = () => (
  <UriBox
    style={{
      flex: 1,
    }}
    source={{
      // XXX: The content type is determined from the source.
      uri: 'http://www.cawfree.com/mapsy/img/mapsy.jpg',
    }}
    lookUpTable={{
      // XXX: The lookUpTable can be used to add support for
      //      additional MIME types.
      ...LookUpTable,
      ['video/mp4']: ({ ...extraProps }) => (
        <Video
          {...extraProps}
          resizeMode="cover"
          loop
          muted
        />
      ),
    }}
  />
);

📌 Prop Types

PropertyTypeRequiredDefault valueDescription
ComponentcustomnoViewDefines the parent for your content. As an example, you could pass an <Animated.View to permit animation.
LoadingComponentcustomnoActivityIndicatorWhat to render whilst loading.
UnsupportedComponentcustomno<See the source code>What to render if the requested MIME type is not supported.
styleshapenostyles.containerParent component styling. The dynamic contents will be sized to fill this .
sourceunionnonullWhat source to render; expects an object with a single key uri.
lookUpTableshapeno<See the source code>Defines the table of mappings to determine which components are used for which MIME types.

✌️ License

MIT