React Testing Tutorial - 40 - Custom React Hooks

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

📱 Follow Codevolution

Custom React Hooks
React Testing Tutorial
React Testing with Jest and React Testing Library
Рекомендации по теме
Комментарии
Автор

Great tutorial! I think it was worth mentioning that hooks can have a custom wrapper too, just like components. Sometimes hooks need access to provider data too!

Middollo
Автор

Thanks @Vishwas for your effort and amazing explanation!

aakashsharma
Автор

Thank you Vishwas for sharing your knowledge with us! Greetings from Argentina.

federicogonzalez
Автор

excuse me, I want to provide a solution to the problem I'm facing from this video,
If you use jsvascript on react and there is an error like this
"TypeError: Cannot read properties of undefined (reading 'initialCount')"

and the solution:
const { result } = renderHook(useCounter, {
initialProps: {
initialCount: 0,
},
});

hope this problem helps you

SYAHRONI_
Автор

How to test that the increment and decrement functions returned from the hook work properly? For example,

const {result} = renderHook(useCounter);



result.current.increment()




Why is second expect failing?

Anteater
Автор

Your decrement and increment functions will not work correctly, as useState uses async setter so the current count value may not always be reflected accurately by using the count variable.

Instead use setCount(prev=> prev + 1)

shanno-markshanahan
Автор

Hi Vishwas. I found on the documentation the rerender method. Is it better to use act than rerender?

equiman
Автор

Thank you so much for sharing your knowledge, i just found your channel and i already suscribed, i can't wait to learn more 🤓❤

OlguisM
Автор

Bro why you end every sentence with the same intonation. 😂 Try speaking more naturally. Clear tutorial, though.

adventurer
welcome to shbcf.ru