#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Debugging Techniques (React)

Breakpoints

A breakpoint is a marker that tells the browser to pause your JavaScript at a specific line. While paused, you can inspect every variable in scope, look at the call stack, and step through the code one line at a time. For React apps, breakpoints are far more precise than scattering console.log() calls, because you see the exact state of props, state and local variables at the moment something goes wrong.

Setting a breakpoint in the browser

Open the developer tools (F12 or Ctrl+Shift+I) and go to the Sources tab in Chrome or Edge, or Debugger in Firefox. Press Ctrl+P to search for your component file by name. Thanks to source maps, which development servers such as Vite generate automatically, you see your original JSX rather than the bundled output. Click a line number to add a breakpoint, then trigger the code, for instance by clicking the button whose handler you want to examine.

The debugger statement

You can also pause from inside your code by writing the keyword debugger. When dev tools are open, execution stops on that line. When they are closed, the statement does nothing. This is handy for code that is hard to find in the file list.

function CartSummary({ items }) {
  const total = items.reduce((sum, item) => {
    debugger; // pauses here once per item while dev tools are open
    return sum + item.price * item.qty;
  }, 0);

  return <p>Total: {total}</p>;
}

Remove every debugger line before committing, since it is easy to forget one and annoy teammates.

Moving around while paused

ControlShortcut (Chrome)What it does
ResumeF8Run until the next breakpoint
Step overF10Run the current line, staying in this function
Step intoF11Enter the function called on this line
Step outShift+F11Finish this function and return to the caller

The Scope panel lists local variables, including props you destructured. Hover over any variable in the code to see its value, or type an expression into the Console while paused; it runs in the paused context.

Smarter breakpoints

Right-click a line number to add a conditional breakpoint, such as item.qty < 0. It pauses only when the condition is true, which saves you from clicking Resume dozens of times inside a loop. A logpoint prints a message without pausing, like a temporary console.log() that never touches your file. The Sources panel can also pause on exceptions, or on DOM changes and event listeners.

Why a breakpoint seems to be skipped

If a breakpoint never triggers, the line may simply not run, so check that the event or condition you expect actually happens. Breakpoints can also sit on the wrong file when you open the bundled code instead of the source-mapped original. Another surprise in development is that React's Strict Mode renders components twice to reveal side effects, so a breakpoint in a component body can pause twice per update. That is expected, not a bug in your code.

Remember

Pause where the bug appears, read the Scope panel, step backward through the call stack to see who passed the bad value, and prefer conditional breakpoints inside loops.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course