Skip to content

Latest commit

 

History

History
29 lines (15 loc) · 1.82 KB

File metadata and controls

29 lines (15 loc) · 1.82 KB

useState() Hook

How does React differ from vanilla JS/HTML/CSS?

React breaks down the UI into smaller and reusable components that can move around data amongst each other. This breaking down of the UI is what gives React an edge over Vanilla JS. ... This is where React comes in with a great feature i.e its own virtual DOM. The virtual DOM is a shortcut to bypass the manual work

What is the primary difference between a function component and a class component?

Functional Components : A functional component is just a plain JavaScript function that accepts props as an argument and returns a React element.

Class Components : A class component requires you to extend from React. Component and create a render function which returns a React element


  • Functional Components : Functional components are some of the more common components that will come across while working in React. These are simply JavaScript function

  • Children / Child Components : A child component is a more specific part inside a parent component. Example would be a parent component being a PERSON. ARMS and LEGS are child components of it.


What is Hooks ?

A hook is a means of executing custom code (function) either before, after, or instead of existing code. For example, a function may be written to "hook" into the login process in order to execute a Captcha function before continuing on to the normal login process.

Why Hooks?

We know that components and top-down data flow help us organize a large UI into small, independent, reusable pieces. However, we often can’t break complex components down any further because the logic is stateful and can’t be extracted to a function or another component. Sometimes that’s what people mean when they say React doesn’t let them “separate concerns.