import React from 'react';
import {Image, ImageProps} from 'react-native';

type SmartImageProps = ImageProps & {
  fallback?: any;
};

export const SmartImage = ({source, fallback, ...props}: SmartImageProps) => {
  const isRemote = typeof source === 'object' && 'uri' in source;
  return (
    <Image source={isRemote && !source.uri ? fallback : source} {...props} />
  );
};
