DEV Community

Discussion on: A quick guide to Testing React hooks that use RxJS

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Great article. But I have this strange feeling that the code would have been slightly easier to read if it didn’t use hooks. I say that because there’s nothing about the code that tells me that your button is stateful. And it is in fact stateful because it literally relies on side-effects (or in React parlance “useEffect”). However we can’t tell that because (a) button is a function component which makes me think it’s stateless and (b) the function that uses useEffect abstracts that away inside of useClick.

tl;dr: if this was a class component then it would be clear that the component is stateful.

That being said, bravo on the testing code! :)