React Flashcards
What is React
An open-source JavaScript library used for building user interfaces. Allows developers to create reusable UI components and efficiently update and render them as the application state changes.
What are the key features of React.js?
Virtual DOM, Component-base architecture, Unidirectional data flow, JSX and supports server-side rendering
What is JSX?
Is a syntax extension for JavaScript used in React.js. Allows you to write HTML-like code directly within JavaScript.
Difference between function and class components
Function components are stateless and defined as JavaScript Functions. Class components, are defined as ES6 classes and have additional features like lifecycle methods and state management.
What is the difference between a controlled and an uncontrolled component?
Controlled component is a component whose state is controlled by React. Receives its current value and change callbacks as props and notifies parent components of state changes. Uncontrolled component stores its own state internally and manages it through the DOM.
What is the significance of the “children” prop in React?
A special prop that allows components to display whatever is included between their opening and closing tags.
What is the difference between props and state.
Both used to mange data. Props are read-only and passed from parent to child component. State is mutable and is managed internally within a component. Used to manage data that can change over time within a component
Significance of the virtual DOM?
Is a lightweight copy of the actual DOM. When there is a change in application state, it is compared to real DOM and only updates the necessary part.
What are React Fragments
Allow you to group multiple elements together without adding an extra DOM.
What is Context API in React?
Creates a global state accessible to any component within a designated context.
Explain the concept of prop drilling in React.
Process of passing props through multiple layers of components in order to reach a deeply nested component that needs to access the data.
How does React handle list and keys
Each item in the list should have a unique “key” prop assigned to it. The “key” prop helps React identify which items have changed, been added, or been removed. Keys improve the efficiency of list rendering and help maintain component state correctly.
What are React hooks
Are functions that allow functional components to use state and other React features without a class.
What is the purpose of useEffect hook
Is used to perform side effects in a React component.
What is the role of the useState hook
Is used to add state to functional components. Returns an array with two element, the current state value and a function to update the value.