React Basics for Beginners
What is React?
React is a JavaScript library made by Facebook to build user interfaces (UIs), especially single-page apps. It
lets you break your web page into small reusable parts called 'components'.
Why Make Different Folders in React?
React apps are bigger than simple HTML pages. So we organize code into folders:
- assets/: for images, icons, etc.
- components/: for reusable UI parts like buttons, to-do list, etc.
- utils/: for helper functions like timers or quotes.
- App.js: main layout
- index.js: starts the app
Basic React Concepts
- JSX: You write HTML inside JavaScript (e.g., return <div>Hello</div>)
- Components: Functions that return UI. Can be reused.
- Props: Like arguments passed to components.
- State: For storing data inside a component (e.g., tasks, input).
- useState(): React hook to create and update state.
- import/export: To reuse code from other files.
Basic Syntax & Examples
1. A simple component:
function Header() {
return <h1>Hello React!</h1>;
2. Using useState:
const [count, setCount] = useState(0);
setCount(count + 1);
React Basics for Beginners
3. Rendering a component:
<Header />
Summary
React helps you build big apps in a clean and reusable way.
Folders help you stay organized.
JSX lets you mix HTML + JS.
useState lets your app change with user input.
You already know HTML/CSS/JS React is the next level!