How NOT to test custom React hooks (and how to test them)

preview_player
Показать описание

It can be tempting to try and call your custom hook manually and test it that way, but you'll run into the error "Hooks can only be called inside the body of a function component." And for good reason. Let's talk about why that is and the proper way to test a custom React hook.
Рекомендации по теме
Комментарии
Автор

I hope the community improves the way to test hooks. That looks like a workaround

DiegoArcega
Автор

That's all good for custom hooks but how would you test the useEffect hook???

OnTheSpurOfTheMoment
Автор

What's the idea behind putting the `count` variable into the string template in the JSX?

staggermeister_old
Автор

this is the worst way to tech something, you use complex things even you struggle yourself understanding, first 5 min and stopped watching

learnbit_bo
Автор

How to test little state machine, can you put a video on this useStateMachine

tanveerakram
Автор

When I run my updated function (the setState returned from hook), I got a warning saying to wrap it in an `act method. Is there a reason that didn't show for you?

Episey
Автор

I couldn't understand the reason in changing the useCounter return type from array to object. How is that going to affect the return value when the value changes. Can anyone explain this ?

lokeshpathrabe
Автор

Will you do a video on your youtube setup? Specifically thinking about the green screen.

qodesmith
Автор

Is there a way to test how custom hook reacts on props change ? i.e. if you have useEffect in your custom hook and you want to test that logic

oskarsrukmans
Автор

how to test a component with multiple custom hooks ?

sitcomrave