React Interview Questions
November 23, 2019
What is React?
- It follows the component based UI approach. Reusability of components makes it very powerful.
What is the Virtual DOM?
- Lightweight JS object which originally is just a copy of the real DOM. It is a node tree that lists the elements.
- React's render function creates a node tree out of the React Components. It then updates the tree in response to the mutation in the data model which is caused by various actions done by the user or by the system.
Class v.s. Functional Components
- Class - allow us to use additional features such as local state and lifecycle hooks.
- Functional - are those that just receive props and renders them to the page, or a component with HTML only
Is State and Props immutable or mutable?
- State is mutable and Props are immutable
State v.s. Props
- State - a data structure (or object) that starts with default values when the component mounts. State is mutable
- Props - are how components talk to each other. They are received from above components. Props are immutable
What is create-react-app?
- This is the official React CLI that generates projects with built in configuration.
What is a PureComponent?
- It is exactly the same as a Component except it handles the shouldComponentUpdate method for us. When props or state changes, PureComponent will do a comparison on both props and state.