Using React.memo() in React 16.6
React 16.6 was released a couple of days and and it brings a couple of new features. One of these is React.lazy() which is something that requires a separate post in itself along with React Suspense....
View ArticleUsing Emotion js in a react project
CSS in JS is a fairly controversial topic depending on who you talk to. What it gives you is the ability to do is write all your styling in javascript instead of creating a separate CSS file. I really...
View ArticleReact Hooks and Local Storage: Let’s build a ToDo app
React hooks have been around for quite some time. They have been widely adopted by the React community since then and have started becoming the defacto for newer React applications. A react hook allows...
View ArticleUnderstanding the useReducer hook in React
Building upon our React hooks introduction from our previous post on understanding React hooks (useState and useEffect), we will look at the useReducer hook in this post. useReducer hook can be an...
View ArticleLearning context API and the useContext React hook
In this react hooks series, we have already explored the react hooks useState, useEffect, and useReducer. The next react hook we will look into is the useContext hook. As we saw while building our...
View ArticleDetecting click outside component using React hooks
If you have tried developing your own dropdown, modal, or popover in React, you would have come across this. “How do I detect a click outside my react component so that I can close it?” Detecting click...
View ArticleProvide callback to useState hook like setState
If you have been writing class components for a while, you might be familiar with the callback functionality that the setState function provides. setState allows a second parameter to be passed to it...
View ArticleHow to write your own custom React hooks
If you have been using react for a while, chances are you have come across the need to extract some logic into a reusable function. And with React hooks coming into the picture, doing this has become a...
View ArticleUse redux-like middleware for useReducer in React
If you have used Redux before, you would be aware of the concept of middlewares. Now that useReducer has become a commonly used react hook, we might want to replicate the idea of middleware for the...
View ArticleUnderstanding the useRef React hook
Continuing our React hooks series, we will learn about the useRef React hook in this blog post. The useRef React hook is useful in the following two situations: Before we see these advantages of the...
View ArticleUsing the useCallback React hook
The useCallback React hook is a useful hook that can help in optimizing the rendering performance of our functional React components. It is used to memoize functions which means it caches the return...
View ArticleAvoiding race conditions and memory leaks in React useEffect
Let us take a look at an implementation of getting data from an API request and see if there is any possibility of race conditions happening in this component: JavaScript We have specified an empty...
View ArticleWhy does React state need a new object/array?
If you have been using React for a while, you are familiar with how state update works. There are a lot of internal optimizations that React makes for faster rendering. One of the implementation...
View ArticleReact fragments: What and Why
React fragments were a feature released in React 16.2. They have been around for a while now but have been a relatively lesser used feature. Let us explore the what and why the feature exists. React...
View ArticleHow to convert a React component to an image
Sometimes you want to give the users the ability to download a part of the web application as an image. In that case, you want a way to convert a React component to an image. And it can be...
View ArticleAutomatic batching in React 18 helps avoid re-rendering
Remember the earlier versions of React that used to batch multiple state updates inside event handlers such as click or change to avoid multiple re-renders? React 18 has added automatic batching for...
View ArticleHow to write comments in React (JSX)?
I was recently trying to comment out some logic inside my JSX to add context about what a potentially complex logic. I then realized that comments in JSX are weird. So, how to write comments in React...
View ArticleUsing Font Awesome with React
Font Awesome is a great resource to use various types of icons in your project including well-known social media icons and a lot more. It can be used with any front-end library. In this post, we are...
View ArticleWhy should we not use index as key in React Lists
When working with React, developers often come across the need to render lists of items efficiently. Every item in a list needs to have a key prop assigned to it. It is essential for enabling React to...
View Article