Major features of React are listed below:
- Virtual DOM: It uses the Virtual DOM instead of the real DOM.
- Server-Side Rendering: It uses Server-side rendering (SSR).
- Uni-Directional: It follows Uni-directional data flow or data binding.
- Components: It uses reusable UI components.
npm install -g create-react-app
For Linux and Mac:
sudo npm install -g create-react-app
props are immutable passed into react components.
State of a component is an object that holds some information that may change over the lifetime of the component.
use this.setState() method to change the state.
Whenever you will change the state, the component will be re-render.
Never use this.setState() method inside the render.
If you will use this.setState() inside componentWillUnmount(), component will not be re-render.
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.
There are mainly two types of Components:
- Functional Component (Stateless Component) - Only props, no state
- Class Component (Stateful Component) - Both props and state.
Reconciliation is the process through which React updates the DOM.
Read the Complete Article React.js Interview Questions & Answers