Differentiate between the Real DOM and the Virtual DOM
Real DOM:
- Creates a new DOM if an element updates
Virtual DOM:
- The virtual DOM is like a blueprint. It contains all the details needed to construct the DOM, and can be changed easily. Fast because React figures out the difference between the virtual DOM and the real DOM to get the two trees to match
What is React?
Advantages of React
Limitations of React
What is JSX?
JSX is a JavaScript syntax extension that allows you to write HTML tags directly in your JavaScript code
What is JSX?
JSX is a JavaScript syntax extension that allows you to write HTML tags directly in your JavaScript code
Explain how the Virtual DOM works
Whenever there is a change, React compares the virtual DOM to the Real DOM in order to calculate what changes need to be made to the Real DOM, and will update only the things that need to be changed.
What are props?
Props are passed down from parent to child components throughout the React app, such as variables/data. (Generally used to render dynamic data).
Explain the lifecycle methods of React components
componentDidMount: Executed on client side after first render
componentDidUpdate: Called right after rendering takes place
componentWillUnmount: Called after component is unmounted from the DOM
How do lifecycle methods work in React functional components?
The useEffect hook works similarly to the three lifecycle methods: componentDidMount (initial render), componentDidUpdate (dependency array), and componentWillUnmount (cleanup function).
Controlled components vs uncontrolled components
Controlled components:
- Do not maintain their own state
- Data is controlled by the parent component
- Take in current values through props and then notify the changes via callbacks
Uncontrolled components:
- Maintain their own state
- Data is controlled by the DOM
What is a higher order component?
Higher-order-component (HOC) is a function that takes a component and returns a new component.
What can you do with higher order components?
Reuse code, and abstract state away
What is the significance of keys in React?
The main purpose of keys is to help React differentiate and distinguish elements from each other. It helps React identify what elements have changed/added/removed.
What is Redux?
Redux is a predictable state container for JavaScript applications and is used for managing the application’s state
What are the 3 principles that Redux follows?
What are the 3 principles that Redux follows?
What does single source of truth mean?
In React-Redux applications, when your Redux is a single source of truth, it means that the only way to change your data in UI is to dispatch redux action which will change state within redux reducer. And your React components will watch this reducer and if that reducer changes, then UI will change itself too. But never other way around, because Redux state is single source of truth.
What does single source of truth mean?
In React-Redux applications, when your Redux is a single source of truth, it means that the only way to change your data in UI is to dispatch redux action which will change state within redux reducer. And your React components will watch this reducer and if that reducer changes, then UI will change itself too. But never other way around, because Redux state is single source of truth.
How does data flow through Redux?
What is an action in Redux?
Actions in Redux are an object that have a type property that indicates what type of action is being performed.
What is a reducer in Redux?
Reducers are pure functions that specify how the application’s state changes in response to an action. It returns a NEW state.
Advantages of Redux?