Components (Functional vs Class)
Learn Components (Functional vs Class) (Fundamentals of React, ReactJS) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is a Component? • A component is a reusable, self-contained piece of UI — a JavaScript function (or class) that returns JSX describing what should appear on screen. • Components let you split the UI into independent, reusable pieces and think about each piece in isolation. • React has two ways to write a component: functional (a plain function) and class-based (extends React.Component ).
More lessons in Fundamentals of React
- Introduction to ReactJS
- Single Page Application (SPA)
- Installing Node.js & npm
- JSX Syntax and Rules
- Props in React
- State and the useState Hook
- Event Handling in React
- Conditional Rendering
- Lists and Keys
- Forms and Controlled Components
- useEffect Hook and Side Effects
- Context API
- React Router (Basic Routing)
- Component Lifecycle