useTimeout() React Hook

James Fulford
JavaScript in Plain English
2 min readNov 29, 2019

--

Running out of time! Photo by Brad Neathery on Unsplash

Working with time effects in React is hard. For example, building countdown components is incredibly easy to do wrong if the React component lifecycle is used incorrectly (but can be easy, if you get a useTime hook!).

The same difficulty goes for integrating delayed callbacks into the React lifecycle. We’re going to wrap setTimeout in a React Hook. In this article, we’re going to discuss:

--

--