React - Basic Flashcards
What are the key features of React.js?
- a virtual DOM for efficient rendering,
- component-based architecture,
- JSX syntax for defining components,
- and unidirectional data flow.
What is unidirectional data flow in react?
- Data flows only 1 way from parent to child using props
- If a child needs to change the state it does so via a callback passed down by the parent.
- Using the callback will update the parent components state and cause the parent and subsequent child components to re-render.
What is JSX?
-A syntax extension for JavaScript that allows you to write HTML-like code within your JavaScript files.
Explain the concept of virtual DOM in React.js.
A lightweight copy of the real DOM which allows React to efficiently update and render only the necessary components when there are changes
What is a functional component
JavaScript functions that receive props as input and return JSX elements as output.
What are class components
Now are considered a little bit out dated compared to functional components. They extend the React.Component class and have the lifecycle methods.
What is the purpose of state in React?
- State is used to store and manage data that can change over time within a component.
How do you update state in React?
- You should never update state directly.
- Functional components should use the useState react hook’s setter method to updated the state.
- Class components should use the setState() method to update state.
What are controlled components in React?
- Where the values of form elements are controlled by React state.
What is the significance of keys in React lists?
Used to help React uniquely identify and differentiate between elements in an array of components.
What is React Router?
- A popular routing library for React applications.
- It allows you to define different routes and their corresponding components, enabling navigation and rendering different components based on the URL
What is the purpose of the useEffect hook in React?
- The useEffect hook is used to perform side effects in functional components such as making API calls.
What is the purpose of the useContext hook?
- It provides a way to access values that are globally available to all components within a specific context.
What is the purpose of the useCallback hook?
- Used to return memoized versions of functions in React so that a function is only reloaded when one of the useCallback dependencies has changed.
What is the purpose of the useRef hook?
Allows you to create a mutable reference that persists across renders and doesn’t cause a re-render when it’s value changes.
It is commonly used to access or store DOM elements without triggering a re-render.