DEV Community

Discussion on: React - Hooks as Optional Parameters

Collapse
 
jakecarpenter profile image
Jake Carpenter

Yuck.

I would much rather stub the hook. Either that or build smaller components that make more sense for strict “unit” testing.

Collapse
 
noriller profile image
Bruno Noriller

Hey... I agree with you. But it's... something.

Also, playing around with it, and I should made this explicit, it was a little of a TIL moment.

You check the parameters of WeirdComponent, you have hook and then hook2 taking hook as an argument for it's hook.
It works in this order, but if you change the order it stops working.

And this is JS for you =D