Testing React Hooks

Daw-Chih Liou
3 min readNov 7, 2018
https://commons.wikimedia.org/wiki/File:React-icon.svg

If you’ve been following react community recently, you might notice the hype around the latest proposal about Hooks.

I think they are awesome😎

Dan Abramov wrote an article to give us a first glance and the problems that Hooks are trying to solve. Within a short period of time since the proposal was announced, there are so many creative custom Hooks already that you can experiment with. If you still aren’t quite sure about them, check out Ryan Florence’s amazing talk “90% Cleaner React with Hooks” at React Conf 2018.

With Hooks, we now have a pattern to tap into state and React features like context with functional components. Custom Hooks allow us to separate cross-cutting concerns from components so we can more intuitively reuse logic without Render Props or Higher Order Components. Since custom Hooks are standalone units, we want to test them independently.

Let’s get to it!

--

--

Daw-Chih Liou

Write for developers. Documenting web technology, coding patterns, and best practices from my learnings.