Giter VIP home page Giter VIP logo

react-fruit-list-app's Introduction

react-fruit-list-app

React Fruit List Application to exemplify some React framework features.

Implementation goals

Implement a feature to allow item selection with the following requirements:

  1. Clicking an item selects/unselects it.
  2. Multiple items can be selected at a time.
  3. Make sure to avoid unnecessary re-renders of each list item in the big list (performance).
  4. Currently selected items should be visually highlighted.
  5. Currently selected items' names should be shown at the top of the page.

Feel free to change the component structure at will.

Proposed solution

To allow multiple item selection, goal number 3 on the goals list above, at the time we use a selectedItems array on the List component to hold the selected items but we use a little trick. Instead of implementing a classic React useState hook on the component to manipulate the selectedItems list and trigger a component re-render on every item select or deselect action, we use a simple array constant and manipulate it without ever changing the variable reference. This "trick" leverages the possibility of using an array for collecting the selected values without triggering re-renders to the list component unnecessarily, thus avoiding heavy re-rendering operations since the list holds a vast number of children.

For style generation we follow the BEM methodology, as suggested by the initial implementation.

The relevant files for this implementation are located inside the src/components folder and src/tools/constants.ts.

The code is commented in the relevant places for better understanding of each implementation goal.

Application Tech Stack

  • React framework (with Typescript) for the overall application development;
  • Typescript coding language;
  • SASS style pre-processor to build the needed application styles;
  • DotEnv to load project environment variables;
  • Webpack to bundle the application and serve it in development mode;
  • PicniCSS lightweight CSS framework for UI styling;

Application Support tools

  • Prettier for code formatting;
  • Webpack to bundle the application and serve it in development mode;
  • Log4Brains to manage Architectural Decision Record (ADR) and generate static HTML knowledge base;
  • Statoscope to generate reports about the application;

Application Testing tools

  • Jest javascript testing framework;
  • React Testing Library testing framework for working with React components;

Installation and application bootstrap

From the project root folder, please execute the following commands in a terminal window:

npm i
npm start

react-fruit-list-app's People

Contributors

andreros avatar

Watchers

 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.