DEV Community

Rajukst
Rajukst

Posted on

Reactjs Explore

Component Lifecycle: React web apps are actually a collection of independent components
that run according to the interactions made with them. Every React Component has a
lifecycle of its own; lifecycle of a component can be defined as the series of methods that
are invoked in different stages of the component’s existence. Mainly React component
lifecycle are 3 stages. They are Initialization, mounting, updating, unmounting.
Initialization: This is the stage where the component is constructed with the given Props
and default state. This is done in the constructor of a Component Class.
Mounting: Mounting is the stage of rendering the JSX returned by the render method itself.
Updating: Updating is the stage when the state of a component is updated and the
application is repainted.
Unmounting: As the name suggests Unmounting is the final step of the component
lifecycle where the component is removed from the page.
context API: Context API is a way to produce global variables that can be passed around.
Context API moving props from grandparent to child, child to parent. Context API works
effectively. Mainly Context API returns a consumer and provider. Provider is a component
and it suggests provides the state to its children. To create context API need to write
createContext()
Custom Hook: Custom hook is a JavaScript function which created by ourselves, when
share logic between other JavaScript functions. It allows to reuse some piece of code in
several parts of app.
Virtual Dom: Virtual DOM is a copy of the original DOM kept in the memory and synced with
the real DOM. Virtual DOM has the same properties that the real DOM. but virtual DOM lacks
the power to directly change the content. Differences between virtual and real dom: real
DOM just to get things straight forward. Virtual DOM is just a copy of real DOM.

Top comments (0)