Choose React or static HTML for a small page
Start with the page requirements
React is useful when an interface has several pieces of changing data, reusable UI patterns, or interactions that need to stay consistent. A simple page with fixed text and links may need only HTML and CSS. A page can also use plain JavaScript for a small interaction. Adding React introduces dependencies and a development workflow, so choose it for a reason, not by default.
A static page
A reading-room notice with no changing data can use ordinary HTML. A browser can display this document without a JavaScript bundle.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Reading room</title> </head> <body> <main> <h1>Reading room</h1> <p>Open from 9 AM to 5 PM.</p> </main> </body></html>Expected display: the heading and opening hours. A regular browser can render this without React. HTML is still relevant when you use React: the rendered UI should have meaningful headings, buttons and other elements.
A small direct DOM interaction
For a single button, plain JavaScript can listen for activation and change a specific paragraph. The example is a complete HTML file; the script runs after the paragraph and button have been created.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Notice</title> </head> <body> <p id="notice">No announcement.</p> <button id="show" type="button">Show announcement</button> <script> document.getElementById("show").addEventListener("click", () => { document.getElementById("notice").textContent = "New books arrived."; });
</script> </body></html>Before activation, the paragraph says “No announcement.” After activation, it says “New books arrived.” Here getElementById finds an existing DOM element; textContent changes its text. The event handler is a function that runs on activation. This pattern is perfectly reasonable for a small interaction.
The same behavior as a React component
With React, the displayed announcement can be calculated from a remembered boolean value (true or false). This preview uses useState and a conditional expression; these will be covered in detail later.
import { useState } from 'react';
export default function Notice() { const [shown, setShown] = useState(false); return ( <section> <p>{shown ? 'New books arrived.' : 'No announcement.'}</p> <button type="button" onClick={() => setShown(true)}> Show announcement </button> </section> );}The expression condition ? first : second selects the first value when the condition is true and the second when false. Expected behavior matches the plain JavaScript example. React makes the relationship between shown and the paragraph explicit. For several independent notices, a reusable component could reduce repetition.
Choose by complexity, not popularity
Use static HTML for a fixed information page; consider plain JavaScript for isolated interactions; consider React for a task planner with editable rows, filtering and shared UI data. You can add a React-controlled section to an existing site without rewriting the entire site. React itself does not supply every routing, database or hosting decision. Frameworks and other tools may provide those services.
Practice and next step
Choose a starting approach for a restaurant opening-hours page, a single show/hide control, and a task dashboard with several related interactive views. Justify each choice. Chapter 2 reviews the JavaScript building blocks used throughout React.