0.1.0 • Published 2 years ago

@codemantion/lazy-load-image v0.1.0

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

About the project

A simple and lightweight React Component to lazy load images

Installation

Installalation

  • npm
    npm install @codemantion/lazy-load-image
  • yarn
    yarn add @codemantion/lazy-load-image

LazyImage Usage

import React from 'react';
import LazyImage from '@codemantion/lazy-load-image';

const MyComponent = () => (
<React.Fragment>
  <LazyImage
    alt={'my-logo'}
    height={400}
    src={LOGO} // You can import a logo or use an url
    width={400} 
  />
</React.Fragment>
);

Props

PropTypeRequiredDefaultDescription
srcstringtrueThe image source. It can either pass a base64 object or URl can directly be used.
widthnumber200Image Default width. You can pass a number (i.e. 200) or a string (i.e. '200px').
heightnumber200Image Default height. You can pass a number (i.e. 200) or a string (i.e. '200px').
altstring'N/A'Alternative text if the image doesn't render.
styleobject{ }Element Inline Style. You can simply pass the css attribute inside the style attribute.

Global override

You can pass parameters to apply on all the LazyImage components globally.

import { overRideConfig } from '@codemantion/lazy-load-image';

To enable Server side rendering

overRideConfig({ ssr: true });

Global override Props

PropTypeRequiredDefaultDescription
ssrbooleanfalseThis will enable server side rendering(SSR).