Cool React

Rakib
2 min readMay 7, 2021
  1. React major features.
    React uses VirtualDOM instead of RealDom. RealDom manipulations are expensive
    React data flows down. You can pass data from parent to child component, You can’t pass data from child to parent component. React support only unidirectional data flow.
    Uses reusable components to develop User Interface.
  2. What is JSX?
    JSX is JavaScript syntax extension(JavaScript XML), it’s XML like syntax extension. Basically it is syntax sugar of React.createElement() function

3. What is State?
State is dynamic data that can change over the component lifetime. We store our dynamic data in State if we change state React automatically updates our UI. We should always try to make our state as simple as possible.

4. React vs HTML event handling.
In HTML event names are lowercase. In React Event name is camelcase.
HTML event accepts a string, where React event accepts a function.
In HTML you can preventDefault() with return false, But in React you must explicitly call preventDefault()

5. What is a higher-order component?
A higher-order component is a function that receive a Component as an argument, and return a modified component.

6. Difference between state vs props.
State like a store where we can store our data. State is dynamic data that can change over the component lifetime. State is managed within the component similar to variable declaration in a function. State is mutable
Props pass data to the component similar to function parameter. Props is immutable

7. What is Virtual DOM?
Virtual DOM is a memory representation of Real DOM. Whenever a state was changed a Virtual DOM is created. With diff algorithm, its checks previous Virtual DOM and updates UI what should need.

8. Controlled Components.
An input form element whose value is controlled by React in this way is called a Controlled Components, and which input value can’t be controlled by React is called Uncontrolled components.

9. Lifting state up.
When many components need to share the same changing data then it is recommended to lift the shared state up to their closest common ancestor. React data flows down so we need to store data to the parent component.

10. Context API.
The React Context API is a way for a React app to effectively manage global state that can be passed around. This is the alternative to “prop drilling” or moving props from grandparent to child to parent, and so on. Context is also treated as an easier, lighter approach to state management using Redux

--

--