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

If use-react-screenshot produces an image that differs from the React component, start by checking the element you capture and your dependencies, then work through html2canvas’s DOM, CSS, browser-security, and canvas-size limits. The hook is an entry point; html2canvas reconstructs an image from the DOM rather than recording the browser’s rendered pixels.

What “incorrect rendering” means

Different symptoms point to different causes. Identify the symptom before changing options:

  • Missing text, borders, shadows, gradients, or layout details: the relevant CSS may be unsupported or only partially implemented by html2canvas.
  • Missing images or a security error: an image is probably cross-origin and cannot be read into the canvas.
  • An iframe is empty: the frame may be cross-origin or sandboxed without same-origin access.
  • The capture is blank, clipped, or only shows the viewport: the requested canvas or viewport may be too small—or beyond the browser’s canvas limits.
  • Blurry output or unexpected dimensions: inspect the scale and the element’s actual rendered size.

There is no universal configuration switch. Your browser, CSS, assets, iframe origins, and output dimensions determine the result.

1. Verify the target and installation

Capture the element that is actually rendered

A ref must point to the intended, mounted element—not a component function, a stale node, or a wrapper whose size differs from what you see. Capture after the content is present and fonts or images have had an opportunity to load.

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.
import React, { useRef } from 'react';
import { useScreenshot } from 'use-react-screenshot';

export default function CardShot() {
  const targetRef = useRef(null);
  const [image, takeScreenshot] = useScreenshot();

  const capture = async () => {
    if (!targetRef.current) return;
    const result = await takeScreenshot(targetRef.current);
    console.log(result);
  };

  return (
    <>
      <button onClick={capture}>Capture</button>
      <div ref={targetRef}>Content to capture</div>
      {image && <img src={image} alt="Captured component" />}
    </>
  );
}

Use the package’s documented hook API for your installed version; naming and return values can differ between releases. Confirm that React and html2canvas are installed as peer dependencies alongside the hook. A dependency mismatch can look like a rendering defect, so check the versions resolved by your application and the html2canvas documentation for that version.

Make the failure reproducible

  1. Reduce the target to the smallest element that still differs.
  2. Remove animations, carousels, transitions, and lazy content temporarily.
  3. Record browser name and version, viewport dimensions, device-pixel ratio, and whether the page is served over HTTP or HTTPS.
  4. Compare the DOM in DevTools with the capture target, including computed styles and actual scrollWidth/scrollHeight.

2. Check CSS support before changing options

html2canvas reads DOM nodes and style information, then paints its own representation. It does not ask the browser for a native screenshot. Unsupported or incomplete CSS therefore appears as a missing or altered feature; no option can make an unimplemented property render correctly by default.

Isolate the CSS property

Temporarily replace complex styles with simple equivalents:

  • Replace a gradient with a solid background.
  • Replace a filter or blend mode with a pre-rendered image.
  • Replace an advanced shadow with a basic box shadow.
  • Remove pseudo-elements and verify whether their content is absent.
  • Disable transforms, sticky positioning, masks, and complex clipping one at a time.

When the simplified version works, add styles back individually. Keep a capture-specific class that supplies a supported fallback rather than trying random global settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Dynamic and layout-dependent content

Capture after React has committed the state you want. Wait for data, web fonts, images, and layout changes. Freeze animations and transitions during capture so the cloned DOM is not sampled midway through a change. If a component depends on hover, focus, or a media query, set that state explicitly before calling the hook.

3. Resolve cross-origin images

A browser may display a remote image while still refusing to let script read it into a canvas. html2canvas’s useCORS: true option works only when the image server supplies an appropriate Access-Control-Allow-Origin response header. It cannot bypass browser policy.

Preferred fixes

  • Serve the asset from the same origin as the page.
  • Configure the image host to return a suitable CORS header and then use useCORS: true.
  • Proxy the image through your own server so the browser receives it from your origin.
  • Replace the remote asset with an inline data URL when that is practical and permitted.
const canvas = await html2canvas(node, {
  useCORS: true,
  onclone: (clonedDocument) => {
    // Apply capture-only styles to the cloned document if needed.
  },
  onerror: (error) => console.error('Resource failed', error)
});

If the server does not cooperate, remove the image or proxy it; repeatedly toggling useCORS will not change the policy decision. Check the browser console and Network panel for blocked image responses.

4. Check iframes and sandboxing

Same-origin iframe content can be rendered recursively because the page can access its contentDocument. Cross-origin iframe content cannot be read by the parent page. A sandboxed iframe without allow-same-origin has the same practical restriction.

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

What to do

  • Capture the iframe’s own page from code running inside that frame.
  • Host the frame content under the same origin when your security model allows it.
  • Render an equivalent placeholder in the parent document for the image.
  • Use a browser-level screenshot method when you need the frame’s actual pixels and cannot change origins.

5. Fix blank or clipped output

Match html2canvas’s viewport to the element

For an element that extends beyond the visible viewport, pass its scroll dimensions as the rendering viewport. This is a documented troubleshooting step for empty or cut-off canvases.

const node = targetRef.current;
const canvas = await html2canvas(node, {
  windowWidth: node.scrollWidth,
  windowHeight: node.scrollHeight
});

Use the equivalent options through your hook’s html2canvas configuration. Measure after layout has settled; a hidden or collapsed element reports misleading dimensions.

Respect browser canvas limits

Canvas maximum width, height, and total area vary by browser and platform. A very tall full-page capture can become blank or partial without a useful exception. Reduce the target, capture sections separately, lower the scale, or export several pages instead of one enormous canvas.

Understand scale and pixels

The scale option controls output pixel density. A higher value can improve text sharpness but multiplies memory and canvas area. Start with the default or device-pixel ratio, then increase only after a correctly sized capture works.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

6. Use options as diagnostics, not magic fixes

html2canvas exposes targeted controls. Apply one at a time and keep a known-good baseline:

  • scale: change output density and test for memory or dimension failures.
  • windowWidth/windowHeight: reproduce the layout needed for a full element.
  • onerror: log resource-loading failures when supported by your installed version.
  • Exclusion controls: omit chat widgets, ads, video, or unstable elements that cannot be reconstructed.
  • Copied-style adjustments: apply capture-only CSS to the cloned document rather than changing production appearance.

Option names and callbacks follow the html2canvas version installed in your application. Check that version’s configuration reference instead of copying settings from an unrelated release.

7. Decide whether DOM reconstruction is sufficient

The official characterization is important: the output is based on the DOM and “may not be 100% accurate to the real representation” because it builds an image from available page information rather than taking an actual screenshot. If pixel fidelity is mandatory, choose a capture method that matches where your code runs.

Requirement Better fit Trade-off
Capture a component in the current React page use-react-screenshot/html2canvas CSS, CORS, iframe, and canvas limits apply
Capture browser-rendered pixels in an extension Native browser screenshot APIs Requires extension permissions and browser-specific code
Generate screenshots on a server Puppeteer or Playwright Requires a browser runtime, resource controls, and server capacity

Compare alternatives by execution location, pixel fidelity, cross-origin access, support for dynamic content and CSS, and output-size limits—not by a single “quality” setting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For repeatable URL screenshots, ScreenshotNeo runs the capture in an API and MCP server instead of your React page. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

One GET request returns PNG, JPEG, WebP, or PDF. The API supports full-page lazy-image loading, CSS-selector element capture, dark mode, device presets or custom viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, clicks, waits, blocked resources, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification.

cURL

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

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo API documentation for authentication, output parameters, and advanced options. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools to Claude, Cursor, and other MCP clients.

ScreenshotNeo includes 1,000 screenshots per month free with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account.

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

Troubleshooting checklist

  • Target is null: capture after mount and confirm the ref is attached to the intended DOM element.
  • Text or CSS is missing: isolate the property and provide a capture-specific supported fallback.
  • Images disappear: inspect CORS headers; use same-origin hosting or a proxy.
  • Iframe is blank: verify same-origin access, sandbox flags, or capture inside the frame.
  • Output is clipped: pass measured scroll dimensions and check overflow containers.
  • Output is blank at large sizes: reduce scale or split the capture because canvas limits vary.
  • Capture is inconsistent: wait for data, fonts, images, and network activity; disable animation.
  • Errors appear after an upgrade: compare the hook, React, and html2canvas versions and use the matching configuration reference.

Frequently Asked Questions

Can use-react-screenshot capture a cross-origin iframe?

No. Parent-page script cannot access a cross-origin iframe’s contentDocument. Capture inside the frame, make it same-origin, or use a browser-level screenshot method.

Does useCORS allow any remote image?

No. It only succeeds when the image server returns an appropriate Access-Control-Allow-Origin header; otherwise use same-origin hosting or a proxy.

Why does increasing scale make a blank image?

Scale increases canvas pixel dimensions and memory use. The result can exceed browser-specific canvas limits; lower scale or split the capture.

The Bottom Line

Fix incorrect use-react-screenshot output by classifying the failure, verifying the target and dependencies, isolating unsupported CSS, resolving CORS and iframe restrictions, and matching viewport and canvas dimensions. When you need actual browser pixels rather than DOM reconstruction, use a browser screenshot API or a server-side browser.

Free tools Windows power users keep installed

One-click scans. No signup required.

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.