No one is perfect, and it often takes several iterations before the desired outcome is achieved. You have to peek into the code in real time to identify certain failure points. Debugging is a skill and can only be mastered with practice.
Debugging is an essential part of the software development life cycle. Not only does it allow the developers to validate their logic, but it also uncovers some areas of improvement. Since all the logic for SPFx web parts exists inside the JavaScript file, we are going to use our JavaScript debugging skills here.
There are two styles of debugging that people use:
- Logging: One of the ways to debug the execution flow is by adding console.log() statements to your JavaScript file at various places. The debugger prints the messages in the order in which they are encountered.
- Using developer tools: This is a more useful way to debug your code by adding breakpoints, watching, and...