October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Troubleshoot and Fix Common React Bugs

A practical guide to diagnosing unexpected renders, repeated Effects, stale state, and child crashes in React.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a React component renders unexpectedly, state appears stale, an Effect repeats, or a child crashes, start by reproducing the smallest failing interaction and capturing the exact console message and stack trace. Then inspect the component’s props and state in React Developer Tools. Match the evidence to the symptom before changing code: common causes include impure render logic, mutated or redundant state, incorrect Effect dependencies or cleanup, and errors thrown while a child renders.

Start with evidence, not a guessed fix

  1. Reproduce the issue. Use the smallest interaction that reliably triggers it. Note what you expected and what happened.
  2. Read the browser console and stack trace. Follow the trace to the relevant component or state setter. When a state update’s cause is unclear, React’s useState reference recommends inspecting the console stack to identify the setter involved.
  3. Inspect the live component tree. The official React Developer Tools includes Components and Profiler panels. Components helps you inspect a component and its props and state; Profiler helps investigate repeated or expensive updates.
  4. Change one likely cause at a time. Repeat the same interaction after each change, and check both visible behavior and console output.

This sequence narrows the problem before you alter code that may not be responsible.

Why is my React component rendering twice?

A repeated render is a clue to investigate, not automatically a production bug. In development, Strict Mode performs extra checks, including additional renders intended to reveal impure components. First establish whether the behavior occurs only in development under Strict Mode or also in a production build.

Check whether render is pure

React expects a component to return the same output for the same props, state, and context. Rendering should not mutate props or state, or perform side effects. These rules make component behavior predictable and help React optimize code; see Rules of React.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Look for work that changes something outside the component while its function is running, or code that alters an object or array received through props or state. Move external synchronization into an Effect, or handle a user action in its event handler. Keep render focused on calculating the UI.

Use Strict Mode as a diagnostic

If the extra development checks expose a subscription that is registered twice, a counter that changes during render, or another inconsistent result, fix the underlying impurity or missing cleanup. Do not treat disabling Strict Mode as proof that the bug is fixed: the check is designed to expose issues early.

Why is my useEffect running twice or causing a loop?

An Effect is for synchronizing a component with an external system, such as a subscription, timer, connection, or browser API. If there is no external system involved, the Effect may be unnecessary. React’s guidance on synchronizing with Effects and when you might not need an Effect can help distinguish synchronization from ordinary data derivation.

Verify the dependencies

Compare the dependency list with the reactive values the Effect reads. A missing or incorrect dependency can leave an Effect working with outdated values; dependencies that change on every render can repeatedly trigger it. Inspect each dependency and determine why it changes rather than suppressing the warning or adding dependencies blindly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make cleanup undo setup

If setup subscribes, starts a timer, or opens a connection, cleanup should unsubscribe, clear the timer, or close the connection. Strict Mode deliberately probes Effect setup and cleanup in development, so a setup-cleanup-setup sequence should leave the external system in a correct state.

Avoid a “run once” ref used merely to silence a repeated Effect. React’s Effect guidance identifies this as a common pitfall when the real problem is missing cleanup. Make setup and cleanup safe instead.

Move derived calculations and user actions out of Effects

If an Effect only computes a value from props or state, derive that value during render. If work should happen because a user clicked a button or submitted a form, put it in that event handler. This reduces unnecessary state updates and avoids Effects that trigger more renders without synchronizing anything external.

Why is my React state not updating?

Check the setter call, the value passed to it, and whether the next value is actually different. React ignores a state update when the next value is Object.is-equal to the current value, as described in the useState reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not mutate existing objects or arrays

Instead of changing an object or array already held in state and passing the same reference back, create a new object or array that represents the next state. Reusing the same reference can make the update appear unchanged. Inspect the setter’s inputs in the component tree and the console stack if it is unclear which update is responsible.

Remove redundant state

Keep state minimal. If one value can be calculated from another, storing both creates an opportunity for them to drift out of sync. React’s Managing State guidance identifies redundant or duplicate state as a common source of bugs. Derive values during render when appropriate, and reserve state for values that need to persist between renders and change over time.

What should I do when a child component crashes?

A try/catch around a component’s JSX return does not catch an error thrown later while React renders a child. Put an Error Boundary above the subtree that may fail so it can handle descendant render errors and show a fallback UI. The React lint documentation explains this limitation in its guidance on Error Boundaries.

Use the stack trace to locate the failing descendant, then inspect the props and state that reach it. An Error Boundary addresses the failure presentation; it does not repair the underlying cause of the child’s exception.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Could React Compiler be involved?

If a runtime issue began after enabling React Compiler, check for violations of the Rules of React before assuming the compiler itself is the cause. The official React Compiler debugging guide lists failure patterns that include unstable Effect dependencies and reliance on referential equality. Inspect the values involved and whether the component or Hook assumes an object identity will remain stable.

Quick symptom-to-check guide

Symptom First checks Likely direction
Repeated or inconsistent render Does it happen only in development with Strict Mode? Does render mutate values or perform side effects? Keep render pure; treat Strict Mode’s extra checks as diagnostic evidence.
State appears unchanged or stale Is the setter called with the intended next value? Was an object or array mutated in place? Is the next value Object.is-equal to the current one? Use immutable updates and remove state that duplicates a derivable value.
Effect repeats, loops, or leaks Does it synchronize with an external system? Are all reactive dependencies correct? Does cleanup undo setup? Correct dependencies and cleanup, or replace an unnecessary Effect with render-time derivation or event handling.
Child render throws Which component appears in the stack trace? Is there an Error Boundary above the subtree? Use an Error Boundary for descendant render errors, then investigate the child’s inputs and failure.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your React debugging task needs a screenshot of a page, ScreenshotNeo can capture one with a single GET request. Its API can return PNG, JPEG, WebP, or PDF; the example below saves a WebP screenshot.

See the ScreenshotNeo API documentation for parameters and response details. Replace the example URL with the page you need to capture.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers indicate the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents, including Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Does a repeated render mean React is broken?

No. A development-only repeat under Strict Mode can be an intentional diagnostic check; investigate purity and whether the issue also occurs in production.

Should every value used in a component be stored in state?

No. Values that can be derived from existing props or state generally do not need duplicate state.

Can I catch a child’s render error with try/catch around JSX?

No. Use an Error Boundary above the descendant subtree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.