useEffect

Avoiding race conditions and memory leaks in React useEffect

Avoiding race conditions and memory leaks in React useEffect

  • February 8, 2021

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: We have specified an empty array as a dependency to the useEffect React hook. So we have ensured that the fetch...

Provide callback to useState hook like setState

Provide callback to useState hook like setState

  • December 15, 2020

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 as a callback. The callback function is invoked whenever the state of the function gets updated. But,...

React Hooks and Local Storage: Let’s build a ToDo app

React Hooks and Local Storage: Let’s build a ToDo app

  • August 25, 2020

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 developers to hook into React features. React hooks allow building components by using functions instead of...