Rock Mountain
  • Home
  • User Guide
    • Glass Web Components
    • Using reCAPTCHA
    • Publishing Source Code with Syntax Highlighting
  • Developer Guide
    • Getting Started
    • Adding NPM Packages
    • Database
      • Backing Up and Restoring Data
      • Database Schema
      • MongoDB Tips and Snippets
      • VS Code and the MongoDB Playground
    • Common Errors and Their Solutions
    • Developing Glass Web Components
    • DevOps
      • Build and Deployment Procedure
      • GitHub Conventions and Workflow
      • Merging Preview Into Main
    • File Structure
    • React Components
      • SiteLayout Component
      • Toggle Lazy Load Image Component
    • Update or Change the Fav Icon
    • References and Learning Resources
  • Icons
Powered by GitBook
On this page
  • Setup and Usage
  • Attributes
  1. Developer Guide
  2. React Components

Toggle Lazy Load Image Component

PreviousSiteLayout ComponentNextUpdate or Change the Fav Icon

Last updated 3 years ago

The ToggleLazyLoadImage component provides the ability to toggle between two images on a click. This component depends on the . We are using this instead of the Next.js Image component because, for now anyway, it supports a fluid image that fills the photo grid we use showing photo albums/collections. We could not get the Next.js Image component to act fluid and properly fill its card on the photo grid.

Image 1 is clicked...

...to reveal Image 2

Setup and Usage

Import the component as follows:

import ToggleLazyLoadImage from 'components/ToggleLazyLoadImage'

Within your JSX use the tage as shown:

<ToggleLazyLoadImage image1={img1} image2={img2} cname="card-img-top"/>

Attributes

Property
Type
Required
Description

image1

string

yes

URL for the default (initial) image to be shown

image2

string

yes

URL for the next image to be shown (in the toggled state)

React Lazy Load Image component