React Core Concepts Flashcards
Learn the core concepts of React
Components
Components are like building blocks for your app.
Each component is a small, reusable piece of your user interface (UI), like a button or a form.
Functional Components
These are simple functions that return what the UI should look like.
Class Components
These are a bit more complex and used to be the main way to create components, but now we often use functional components.
JSX (JavaScript XML)
JSX is a special syntax that looks like HTML but is used in JavaScript. It makes it easier to create and understand the structure of your UI.
Props (Properties)
Props are inputs passed from a parent component to a child component. They are read-only and used to pass data or functions to components.
Props usage
Props allow components to be dynamic and flexible, as they can change based on the parent’s state or data.
State
State is an object that holds data that may change over time and affect how the component renders.
State usage
Each component can manage its own state (especially with theuseStatehook in functional components) and re-render when the state changes.
Hooks
Hooks are functions that allow you to manage state and side effects in functional components.
Introduced in React 16.8, they remove the need for class components in many cases.
useState
Manages local state in functional components.
useEffect
Handles side effects like data fetching or updating the DOM.
useContext
Accesses context values without passing props through every level of the tree.
useReducer
Manages complex state logic, similar to Redux’s reducer concept.
Common Hooks
- useState
- useEffect
Virtual DOM
The Virtual DOM is a lightweight copy of the real DOM.
React uses the Virtual DOM to keep track of changes and update only the parts of the actual DOM that need to be re-rendered.