It’s difficult to describe a general strategy to debug “a lot error shown up” so I will walk you through the process for debugging component level errors:
-
Install the React dev tools extension for your browser of choice:
- Chrome
- Firefox
-
Find the component
I recommend either of these paths:
2.a. Open
React tabfrom your browser dev tools and type in the bottom search bar to lookup components by name.2.b. Open
Elements tab, select some element, and switch back toReact. The component hierarchy will be expanded up until the React component matching the DOM node you selected inElements. -
Inspect the state and props of the component that is behaving incorrectly.
If for some reason you don’t like installing browser extensions, you can throw one or more debugger; statements to set breakpoints that will “pause” the execution of your app and let you inspect the call stack, scope, and errors at these points.