Advance React
Advance React
JSX syntax
Functional components
Event handling
Conditional rendering
Component composition
function App() {
const [users, setUsers] = useState([]);
const [form, setForm] = useState({ name: '', age: '' });
const [loading, setLoading] = useState(true);
const [error, setError] = useState('');
return (
<div style={{ padding: 20 }}>
<h1>React Basics to Advanced</h1>
<form onSubmit={handleSubmit}>
<input name="name" value={form.name} onChange={handleChange}
placeholder="Name" />
<input name="age" value={form.age} onChange={handleChange}
placeholder="Age" type="number" />
<button type="submit">Add User</button>
</form>
{error && <p style={{color: 'red'}}>{error}</p>}
bash
Copy code
npx create-react-app react-basics
cd react-basics
Replace the content of src/App.js with the code above.
bash
Copy code
npm start
🧠 Features Explained:
Concept Where it's Used
JSX <h1>React Basics</h1>
Functional components App, UserCard
Props UserCard({ name, age })
useState const [users, setUsers] = ...
useEffect Simulate fetching data
Controlled form value and onChange on inputs
Conditional rendering loading ? and error &&
Lists with keys users.map(...) with key
Event handling onChange, onSubmit