2 ms·
Ask HN: How do you debug React websites?
How do you do it? I find it to be a very frustrating experience.
- The stack trace in the debugger most of the time gives no useful information.
- Stepping in the debugger rarely gives any errors (except for basic JavaScript errors) and the React errors appears afterwards in the console.
- Setting breakpoints at and stepping into JSX components rarely works.
- Sometimes you get the "Rendered fewer hooks than expected"-thing and the message gives absolutely no useful information at all and the line mentioned in the message is often completely wrong.
Am I missing something? The current strategy is just to stare at the code and print lots of information to the console.
- jollyllama 3y agoHave you tried the "React Developer Tools" Chrome extension? If you get it set up right, it should let you view the state/datastore.
- simonvall 3y agoI have it but I don't really find it that useful. If there is some error it just shows a white page with no information. Sure, it is better than nothing and there have been times when it has helped solving the problem but it doesn't replace what the debugger can do.