React is a popular JavaScript library for building user interfaces. In this tutorial, we'll create your first React application from scratch.
Prerequisites
- Basic JavaScript knowledge
- Node.js installed on your computer
- A code editor (VS Code recommended)
Getting Started
Step 1: Create React App
npx create-react-app my-first-app
cd my-first-app
npm start
Step 2: Understanding the Structure
- src/ - Your application code
- public/ - Static files
- package.json - Dependencies
Step 3: Create Your First Component
function Welcome() {
return <h1>Hello, React!</h1>;
}
Step 4: Add State
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
);
}
Conclusion
Congratulations! You've built your first React app. Keep experimenting and building!
Top comments (0)