What is React? JSX Introduction and Your First Component
What problem React actually solves, how JSX syntax works, and how to build your first component.
When data (like a logged-in user, theme, or language) needs to pass down 4-5 levels through the component tree, doing it with props alone turns into "prop drilling" — every component in between just forwards those props without ever using them itself. The Context API solves this.
// ThemeContext.js
import { createContext } from 'react';
export const ThemeContext = createContext('light');
function App() {
const [theme, setTheme] = useState('dark');
return (
<ThemeContext.Provider value={{ theme, setTheme }}>
<Dashboard />
</ThemeContext.Provider>
);
}
import { useContext } from 'react';
import { ThemeContext } from './ThemeContext';
function ThemeToggleButton() {
const { theme, setTheme } = useContext(ThemeContext);
return (
<button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
Current theme: {theme}
</button>
);
}
No matter how deeply nested ThemeToggleButton is inside Dashboard, it can directly access theme and setTheme without any props being passed down.
createContext → <Provider value> → read with useContext.What problem React actually solves, how JSX syntax works, and how to build your first component.
Set up a modern React project in seconds with Vite, and understand the resulting folder structure.
Build functional components and pass data from parent to child components using props.