Skip to the content.

Reading: useState() Hook

Hooks are functions that let you “hook into” React state and lifecycle features from function components. Hooks don’t work inside classes — they let you use React without classes.

The useState function is a built in hook that can be imported from the react package. It allows you to add state to your functional components. Using the useState hook inside a function component, you can create a piece of state without switching to class components.

How does React differ from vanilla JS/HTML/CSS? React is a Javascript library used for building user interfaces. It allows us to make complex UIs from isolated pieces of code called “components”.

React comes in with a great feature i.e its own virtual DOM. The virtual DOM is a shortcut to bypass the manual work. It is a lightweight copy of the actual DOM.

React use JSX, and JSX stands for JavaScript XML. It is simply a syntax extension of JavaScript. It allows us to directly write HTML in React

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

Children / Child Components: Children allow to pass components as data to other components

image