0.1.5 • Published 4 years ago

react-native-web-fetchimage v0.1.5

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

react-native-web-fetchimage

An image component for react-native-web with persistent disk and memory caching. This comopnent is able to fetch image from api with authorization header.

Installation

npm install --save react-native-web-fetchimage
react-native link

Usage

import React, { Component } from 'react'
import { StyleSheet, Text, View } from 'react-native'
import FetchImage from 'react-native-web-fetchimage'

export default class App extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Sample image</Text>
        <View style={styles.imgContainer}>
          <FetchImage
            style={styles.img}
            source={{
              uri: `${DOMAIN}/assets/image-123`
              headers: {
                Authorization: `authorizaion token`
              }
            }}
          />
        </View>
      </View>
    )
  }
}

const white = '#FFFFFF'
const blue = 'rgb(0,0,255)'
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: white,
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  img: {
    flex: 1,
  },
  imgContainer: {
    flexDirection: 'row',
    flex: 1,
    borderWidth: 1,
    borderColor: blue,
  }
})

License

  • Main source code is licensed under the MIT License.