Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Best way to debug react is to do it via your IDE debug functionality, to enable debugger on caught errors (if you get errors in other code you usually can blackbox it) or to utilize `debugger;` command. Don't forget browser extension for cases where no error happens.


How can you apply this to debugging useEffect issues?


You can set breakpoint inside useEffect and it will work as expected, you can use something like

if (somevar === 42) debugger;

and you'll see all of the internal call stack and all variables in scope. moreover you can use the console to evaluate your code. Worth mentioning 99% of strange issues in react (in my experience) are caused by mutation or not declaring all deps in hooks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: