Giter Club home page Giter Club logo

netix-application's Introduction

Image Gallery With JSON

In the project directory, to run this project run:

Install all the npm packages. Go into the project folder and type the following command to install all npm packages

npm install

In order to run the application Type the following command

npm start

Component Breakdown

The ImageBox component represents a box containing an image and title. The main component, App, renders a collection of ImageBox components.

State Management

The App component uses the useState hook to manage two states: loadedImages and selectedImage. The loadedImages state keeps track of the positions of images that have been loaded, and the selectedImage state holds the URL of the currently selected image.

Image Loading and Click Handling

The ImageBox component receives the necessary props to handle image loading and click events. It utilizes the loadedImages state to determine if the image is loaded and displays a spinner while the image is being loaded. Clicking on an ImageBox triggers the handleImageClick function, which sets the selectedImage state to the URL of the clicked image.

Image Close Functionality

The handleCloseImage function is called when the overlay is clicked, and it sets the selectedImage state to null, effectively closing the overlay.

useEffect for Key Event Handling

The useEffect hook is used to add and remove an event listener for the keydown event. When the escape key (key code 27) is pressed, the handleCloseImage function is called to close the currently displayed image.

Rendering Components

The App component renders a collection of ImageBox components by mapping over the Records array. The first three records are displayed in the first row, while the remaining records are displayed in the second row.

Overlay Display

If the selectedImage state is not null, an overlay is displayed with the selected image in a larger view. Clicking on the overlay triggers the handleCloseImage function to close the overlay.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

netix-application's People

Contributors

shwetd19 avatar

Stargazers

anuj avatar

Watchers

Ashish Kapoor avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.