| by Gagandeep Singh | No comments

undefined and null in Javascript

undefined In Javascript undefined (a primitive type in Javascript) gets assigned to a variable that we declare but don’t assign a value to. It’s Javascript’s way of telling that the value of this variable is not defined. Even a function in Javascript which does not return anything, will return undefined by default. So, to avoid […]

Read More
| by Gagandeep Singh | No comments

Docker – useful commands

To run a container using an image docker run <image name> example: docker run hello-world Override the default command for a container docker run <image name> command example: docker run busybox ls Show running containers docker ps docker ps –all This will list all the containers that were ever created on your machine. Restart stopped […]

Read More
| 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

Browser storage (overview)

Storing data on the machine of the user Data is available to the user on that particular machine and hence cannot be shared with anyone else Example: Storing data such as items in my shopping cart or recently viewed products Different types of browser storage options available are: Local storage / Session storage Cookies IndexedDB […]

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