October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Build a Mini “Shell” Gas Station Calculator with React, useState, and JSON

A concise look at a React learning demo that reads illustrative fuel values from JSON, multiplies the selected price by an entered amount, and displays the result with useState.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This tutorial is a small React learning project: a user selects a fuel type, enters an amount, and sees a receipt-style total calculated from sample prices stored in a JSON object. It is not an official Shell service or a source of current fuel prices.

What the calculator does

The demo presents a fuel dropdown, an amount field, and a Calculate action. When the form is submitted, the component looks up the selected fuel’s sample price, multiplies it by the entered amount, and renders the result in a receipt-like view.

As an Amazon Associate I earn from qualifying purchases.

The author describes the project as split into Header and Content components. That is one implementation choice for this small example, not a required React structure. Hashimov explains, “The goal isn’t to claim I’ve created something "never seen before," but to explain why I made these specific choices.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How the JSON data and calculation fit together

A JSON object holds the example prices and is imported into the component, keeping the values together rather than embedding each one in the calculation logic. The selected fuel type serves as the lookup key. The calculation is:

total = price[selectedFuel] * amount

The source describes parsing the amount from the form input before using it in the multiplication. The JSON values are illustrative code data, not verified fuel rates:

Fuel option in the example Sample value
AI-92 gasoline 1.15
AI-95 gasoline 1.60
AI-98 gasoline 2.30
Diesel 1.10
LPG 0.45
Methane/CNG 0.40
Electricity 0.125

The tutorial does not specify a currency, geography, measurement basis, or date for these figures, and it does not identify an external price source. They should therefore be treated only as sample inputs for the demo, not as prices a driver can expect to pay.

Why the example uses useState

The form’s selected values and calculated result need to be available to the component UI. The tutorial uses React’s useState to hold that information so the interface can render the current selection and result. In the example’s flow, state connects the user’s choices to the displayed calculation; the JSON object supplies the price data.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the tutorial establishes—and what it does not

Hashimov’s DEV Community article, “Mini "Shell" Gas Station with React: useState and JSON DB, is an educational walkthrough of this compact form-and-calculation pattern. It does not establish how to validate input, round or format currency, update prices, persist data, deploy the app, or prepare it for production. Those behaviors should not be assumed to exist in the demo.

The author’s closing note says, “This site is for educational purposes only and has no affiliation with the Shell company.” The name is used in the tutorial title; the project is not a Shell product, an active gas-station service, or a current-price guide.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.