| by Gagandeep Singh | No comments

Using useState hook with the previous state

Let’s take a very basic use case of the useState() hook; updating the count variable on each click. The code look perfectly fine and will work as expected in almost every time. BUT the issue with this code is that setCount() doesn’t guarantee that the previous count that it’s going to use to either increment […]

Read More
| by Gagandeep Singh | No comments

Understanding ReactJS Hooks

React Hooks have been added to React library from version 16.8 and they provide the functionality to use state and few other features inside the functional component without creating React class.  useState The first hook is useState. This let us define a state inside a functional component. useState() returns the current state and a function […]

Read More
| by Gagandeep Singh | No comments

Container vs Presentational Components in ReactJS

Presentational/Functional/Stateless Components Functional components in ReactJS is a simpler way of creating components. Some of the key features of functional components are: It is best suitable for components which only consists of a render method They are also called stateless components since they don’t have an internal state and just make use of props to […]

Read More