Codynn React From Zero Methodology
Build a working React application from scratch by understanding exactly why React exists, how components, props, state, and JSX fit together, and how to wire them into a real project using Vite.
// TL;DR
The Codynn React From Zero Methodology teaches you React by first proving why it exists — you build a feature in plain JavaScript, hit the Manual-Update Problem, then rebuild it in React to see the difference. From there you scaffold a real project with Vite and learn how components, JSX, props, and useState fit together through a strict render pipeline. Use it when you're learning React from scratch, deciding between React and plain JavaScript, scaffolding a new Vite app, or debugging why a component won't render. It's beginner-focused and project-driven.
// When should you use the Codynn React From Zero methodology?
Use this skill whenever a user wants to learn React from zero, evaluate whether to use React vs plain JavaScript for a project, scaffold a new React app with Vite, or understand how components, props, state, and JSX interact in a real codebase.
// What do you need before starting to learn React this way?
- User's goal or project idearequired
What the user wants to build — e.g. a flashcard app, a counter, a dashboard - Prior experience levelrequired
How much HTML, JavaScript, and React the user already knows - Environment preference
VS Code, WebStorm, or other IDE the user is working in
// What core principles explain how React actually works?
The Manual-Update Problem
Plain JavaScript forces you to manually reach into the DOM and update every element that displays a changing value. Every new element means more manual updates. React exists to eliminate this repetition — you declare what should be on screen and React handles the updating automatically.
Component = Function That Returns a Piece of the Screen
A component is always a JavaScript function. That function returns JSX — HTML-looking code — that describes what should appear on screen. The component's name must always start with a capital letter. Every visual unit in a React app is a component.
JSX = HTML-Looking Code Inside JavaScript
JSX is not HTML. It is HTML-looking syntax written inside JavaScript. Vite (the workshop) compiles JSX into real HTML that the browser understands. The advantage is you can inject live JavaScript directly into your markup using curly braces.
useState = How React Remembers Things
useState is the mechanism React uses to track values that will change. You get two things: the current value (e.g. count) and the only way to change it (e.g. setCount). You must use setCount to change count — direct mutation does not trigger a re-render.
Props = Arguments for Components
Props are like HTML attributes you pass when you place a component. They are similar to function arguments — the component receives them as a props object and uses props.propertyName to access them. Props let you reuse one component template with different data each time.
Root = Where Everything Goes
The entire React app renders into one div with id='root' in index.html. main.jsx selects that div, creates a React root, and calls root.render() to place components inside it. This single entry point replaces manually placing every element on the page.
Vite = The Workshop
Vite takes all your files, all your JSX, and all your packages and bundles them into something the browser can display. You do not need to understand its internals — you just need three commands to start it. In dev mode it live-reloads whenever you save a file.
Component Hierarchy
Components live inside other components. App is the top-level component that contains Header, Flashcard, and everything else. Main renders App. App manages its children. This nesting keeps main.jsx clean and lets App orchestrate the full page.
// How do you learn React from zero step by step?
- 1
Demonstrate the Manual-Update Problem with plain JavaScript first
Build the target feature (e.g. a counter) in a plain .html file using document.getElementById, addEventListener, and textContent updates. Then add a second element that also needs to display the same value. Show that every new element requires another manual update in every event listener. This is the problem React solves — never skip this step.
- 2
Show the React equivalent side-by-side using CDN (no install)
Create a second .html file. Load React, ReactDOM, and Babel via CDN script tags. Add a div with id='root'. Write a script of type 'text/babel'. Pull useState out of React with: const { useState } = React. Create a component (capital letter function name), use useState inside it, return JSX with values and onClick handlers inline. Call ReactDOM.createRoot(document.getElementById('root')).render(<ComponentName />). Compare line counts and point out that adding a new display element in React requires zero changes to event listeners — just place the variable in curly braces.
- 3
Scaffold a real project with Vite
Install Node.js (LTS version). In terminal: npm create vite@latest, project name = your app name, select React framework, select JavaScript. Then cd into project folder, npm install, npm run dev. Open the localhost URL. Vite is now the workshop — it handles all JSX compilation and live-reloading.
- 4
Orient the user to the project file structure
Cover only what matters: node_modules (never touch — all library code lives here), public (static assets like images), src (where 99.9% of work happens), src/main.jsx (the entry point — creates root, calls render), src/App.jsx (the top-level component), index.html (contains the div id='root'). Ignore .gitignore, package-lock.json, vite.config.js for now. Always use package.json scripts to know how to run the app.
- 5
Clear App.jsx and write the first custom component from scratch
Delete all default content in App.jsx. Write: function App() { return (<div><h1>Your App Name</h1><p>Your tagline</p></div>); } export default App. Explain that export default is required — without it main.jsx cannot import it. Reload the page to confirm it renders. Then demonstrate: if you remove export default App, the page breaks.
- 6
Apply the four JSX rules to every component written
Rule 1 — A component must return a single wrapping element. If you have multiple siblings, wrap them in a div or use an empty JSX fragment (<> </>). Rule 2 — Use className not class (class is a reserved JavaScript keyword; Vite converts className to class at compile time). Rule 3 — Close every tag, including self-closing tags like <img />. Rule 4 — JavaScript goes in curly braces inside JSX: {variableName}, {2 * 4}, {name.toUpperCase()}. Enforce these rules on every component the user writes.
- 7
Create a new component in its own .jsx file and nest it inside App
Create src/Header.jsx. Write the function, return JSX, add export default Header. In App.jsx import Header from './Header.jsx'. Place <Header /> inside App's return JSX. Show the component hierarchy in browser DevTools: div#root > div (App) > header (Header). Emphasise: components nest inside other components; main.jsx stays clean and only ever renders App.
- 8
Build a data-driven component and pass props to it
Create a component (e.g. Flashcard.jsx) with hardcoded variables for its data (question, answer, category). Return JSX using those variables in curly braces. Export it. Import and use it three times inside App — notice all three show identical data. Then convert to props: in App, pass attributes on the component tag (<Flashcard question='What planet is red?' answer='Mars' category='Science' />). In the Flashcard function signature add props as the argument. Replace hardcoded variables with props.question, props.answer, props.category. Each card now shows different content from the same template.
- 9
Add interactivity with useState
Import useState at the top of the component file: import { useState } from 'react'. Declare state: const [count, setCount] = useState(0). count is the current value, setCount is the ONLY way to change it — never mutate count directly. Use count in JSX via curly braces. Add onClick handlers on buttons: onClick={() => setCount(count + 1)} and onClick={() => setCount(0)}. Show that every element displaying count updates automatically — no manual DOM manipulation needed.
- 10
Apply CSS using className and verify the full render pipeline
Add CSS in index.css or a component-level .css file. Assign className (not class) on JSX elements to match CSS selectors. Import the CSS file where needed. Confirm in DevTools that className in JSX compiles to class in the rendered HTML. Remind the user: the full pipeline is component (JSX) → export → import in App → App exported → imported in main.jsx → root.render() → index.html div#root → browser.
// What are real examples of applying this React methodology?
A user wants to build a quiz app where multiple questions display on screen and a score increments as correct answers are clicked.
First show the manual JavaScript version: each score display element requires its own getElementById reference and manual textContent update inside every click handler. Then rebuild in React: create a QuizCard component with props for question and options. Use useState for score. Place onClick on each answer button calling setScore(score + 1). Render five QuizCard components with different props — all five update automatically when score changes because they reference the state variable directly via curly braces.
A user wants to understand why their component isn't showing on the page despite writing correct JSX.
Walk the render pipeline checklist: (1) Does the component function have export default ComponentName at the bottom? (2) Is it imported in App.jsx with the correct path? (3) Is it placed as a JSX tag inside App's return? (4) Does App.jsx have export default App? (5) Does main.jsx import App and call root.render(<App />)? (6) Does index.html have a div with id='root'? Any missing step in this chain silently prevents rendering.
A user wants to reuse a card component 50 times with different content.
Create one Card component that accepts props (title, description, imageUrl). In App.jsx map over a data array and render <Card key={item.id} title={item.title} description={item.description} /> for each item. The component is written once; props supply the variation. Adding a new card requires only adding an object to the data array — zero changes to the component itself.
// What mistakes should you avoid when learning React?
- Forgetting export default ComponentName — the component renders nothing and no error clearly says why.
- Using class instead of className in JSX — JSX is inside JavaScript where class is a reserved keyword; always use className.
- Mutating state directly (e.g. count = count + 1) instead of using the setter function (setCount(count + 1)) — direct mutation does not trigger a re-render.
- Returning multiple sibling elements without a single wrapping element or JSX fragment — causes 'adjacent JSX elements must be wrapped' error.
- Forgetting to close self-closing tags like <img /> or <input /> — JSX requires every tag to be explicitly closed.
- Placing raw JavaScript expressions outside curly braces in JSX — JavaScript only executes inside {} in JSX; outside it is treated as literal text.
- Manually editing or placing components directly inside index.html div#root instead of routing through main.jsx — defeats the entire purpose of React's component model.
- Starting a component name with a lowercase letter — React treats lowercase tags as native HTML elements, not components.
- Placing logic that updates multiple DOM elements manually when state changes — if you find yourself writing multiple textContent updates, that is the signal to use useState instead.
- Using CDN setup for a real application — CDN is only for quick demos; real applications require the Vite + Node.js setup.
// What are the key React terms you need to know?
- Component
- A JavaScript function that returns a piece of the screen (JSX). Its name always starts with a capital letter. Components can be nested inside other components and reused anywhere in the app.
- JSX
- HTML-looking code written inside JavaScript. It is not real HTML — Vite compiles it into real HTML for the browser. The key advantage: you can inject live JavaScript anywhere inside it using curly braces.
- useState
- How React remembers things. Returns an array of two items: the current value and the setter function. The setter function is the ONLY way to change the value and trigger a re-render.
- setCount (setter function)
- The only way to change a useState value. Calling it updates the value and automatically re-renders every part of the screen that uses that value.
- Props
- Arguments passed to a component, similar to HTML attributes. Written on the component tag in JSX (e.g. question='...'). Received inside the component as the props argument and accessed via props.propertyName.
- Root
- The single div with id='root' in index.html. It is the container where the entire React app gets rendered. Everything in the app ultimately lives inside this one element.
- Vite
- The workshop. A build tool that takes all your JSX files and packages, compiles them, and serves them to the browser. In dev mode it live-reloads on every file save. Started with three terminal commands.
- CDN (Content Delivery Network)
- A web address that loads pre-built code (like React) into a page without installing anything. Used only for quick demos — not for real applications.
- Babel
- A translator used in the CDN demo setup that converts JSX into JavaScript the browser understands. In a Vite project, Vite handles this automatically.
- npm (Node Package Manager)
- Downloads code that other developers have written so you do not have to rebuild everything yourself. Comes bundled with Node.js.
- JSX Fragment
- An empty wrapper tag (<> </>) used when you need to return multiple sibling elements from a component but do not want to add an extra div to the DOM.
- className
- The JSX equivalent of the HTML class attribute. Must be used instead of class inside JSX because class is a reserved keyword in JavaScript. Vite compiles it back to class in the final HTML.
- export default
- The line at the bottom of a component file that makes the component available for import in other files. Without it, any import of that component will fail silently.
- main.jsx
- The entry point of a React application. It selects the div#root element, creates a React root, and calls root.render() to place the top-level App component onto the page.
- The Manual-Update Problem
- The core limitation of plain JavaScript for UIs: every element that displays a changing value must be manually selected and updated in every event listener. Adding more display locations multiplies the manual work. React was built to solve this.
// FREQUENTLY ASKED QUESTIONS
What is the Codynn React From Zero methodology?
It's a beginner-focused approach to learning React that starts by proving why React exists. You first build a feature in plain JavaScript, hit the Manual-Update Problem, then rebuild it in React. From there you scaffold a real project with Vite and learn how components, JSX, props, and useState connect through a strict render pipeline.
What is the Manual-Update Problem in React?
The Manual-Update Problem is the core limitation of plain JavaScript for UIs: every element displaying a changing value must be manually selected and updated inside every event listener. Each new display element multiplies the manual work. React solves this — you declare what should appear on screen and React updates it automatically when state changes.
How do I set up a React project with Vite?
Install Node.js (LTS), then run `npm create vite@latest`, name your project, select React and JavaScript. Next, `cd` into the folder, run `npm install`, then `npm run dev`, and open the localhost URL. Vite becomes your workshop — it compiles JSX and live-reloads on every file save. CDN setups are for demos only; real apps need Vite.
How do I pass data to a React component with props?
Add attributes on the component tag in JSX, like `<Flashcard question='What planet is red?' answer='Mars' />`. Then add `props` as the argument in the component function and access values via `props.question`, `props.answer`. Props let you reuse one component template with different data each time — place the same component multiple times with different attributes.
How does React compare to plain JavaScript for building UIs?
Plain JavaScript forces you to manually select and update every element displaying a changing value inside every event listener — adding more display spots multiplies the work. React eliminates this: you declare state with useState and reference it in JSX via curly braces, and every element using that value updates automatically. React scales cleanly where plain JavaScript grows repetitive.
When should I use React instead of plain JavaScript?
Use React when your UI has values that change and multiple elements need to reflect those changes, or when you want reusable components. The signal is simple: if you find yourself writing multiple manual textContent updates when one value changes, that's when useState and React pay off. For a single static page with no interactivity, plain HTML is fine.
What is JSX and is it the same as HTML?
JSX is HTML-looking code written inside JavaScript — it is not real HTML. Vite compiles it into real HTML the browser understands. The key advantage is injecting live JavaScript anywhere using curly braces, like `{variable}` or `{2 * 4}`. JSX has strict rules: use className not class, close every tag, and return a single wrapping element.
What is useState and how does it work?
useState is how React remembers values that change. It returns two things: the current value (like `count`) and a setter function (like `setCount`). You must use the setter to change the value — direct mutation like `count = count + 1` does not trigger a re-render. Declare it with `const [count, setCount] = useState(0)`.
Why isn't my React component showing on the page?
Walk the render pipeline checklist: does the component have `export default ComponentName`? Is it imported in App.jsx with the correct path? Is it placed as a JSX tag inside App's return? Does App.jsx export default? Does main.jsx import App and call `root.render(<App />)`? Does index.html have a `div id='root'`? A missing link silently prevents rendering.
What results can I expect after learning React this way?
You'll be able to build a working React app from scratch — scaffold with Vite, write custom components, pass props to reuse templates, and add interactivity with useState. More importantly, you'll understand the full render pipeline, so when something breaks you can trace it. You'll know exactly why React exists rather than copying patterns you don't understand.
Why do React component names need a capital letter?
React treats lowercase tags as native HTML elements and capitalized tags as your components. If you name a component with a lowercase letter, React won't recognize it as a component and it won't render correctly. Always start component function names with a capital letter — this is a non-negotiable rule, not a style preference.
What is the difference between class and className in React?
In JSX you must use `className` instead of `class` because JSX lives inside JavaScript, where `class` is a reserved keyword. Vite compiles `className` back into `class` in the final rendered HTML, so your CSS selectors still work normally. Using `class` directly in JSX will cause problems — always use `className` on JSX elements.