react-to-print
Advanced tools
Changelog
3.0.3 (December 22th, 2024)
onAfterPrint
is called, and print iframe is removed, after the print preview dialog has closed. Previously these would happen when the afterprint
event was received which, as noted in the README, may occur immediately in some browsers, rather than when the print preview dialog closes. Thanks sensasi-delightnull
/undefined
initial typesdevDependencies
to latest, including now using React 19 for our examples3.0.3-beta-1
(16th Dec 2024)Changelog
3.0.3-beta-1 (December 16th, 2024)
This is a beta release. Please report any issues in the issue below, thank you!
onAfterPrint
is called, and print iframe is removed, after the print preview dialog has closed. Previously these would happen when the afterprint
event was received which, as noted in the README, may occur immediately in some browsers, rather than when the print preview dialog closes. Thanks sensasi-delightChangelog
3.0.1 (September 30th, 2024)
useReactToPrint
directly to event handlers (this is primarily geared at non-typescript users who are not aware of the new v3 API that prefers the function be wrapped, by changing onClick={printFn}
to onClick={() => printFn()}
)Changelog
3.0.0 (September 28th, 2024)
v3.0.0 brings API modernization, React 19 support, a smaller package size, Shadow DOM support, and improved error handling.
content
renamed to contentRef
and type changed from () => React.ReactInstance
to RefObject<Element | Text>
. The core impact here is that Class components now need to have the ref forwarded via props internally to a DOM nodeonBeforeGetContent
removed. Use onBeforePrint
, which similar to onBeforeGetContent
, now runs before the print iframe is loadedremoveAfterPrint
renamed to preserveAfterPrint
which defaults to false
ReactToPrint
removed. Use useReactToPrint
PrintContextConsumer
removed. Use useReactToPrint
trigger
removed, use the function returned by useReactToPrint
IReactToPrintProps
renamed to UseReactToPrintOptions
useReactToPrint
exportevent?: unknown
type from useReactToPrint
callback. optionalContent
is now the only (optional) argumentcanvas
elements have not properly loadedcopyShadowRoots
, to support copying ShadowRoot
s. Thanks boehlke3.0.0-beta-3
(19 Aug 2024)3.0.0-beta-2
(19 Aug 2024)3.0.0-beta-1
(15 Jul 2024)Changelog
2.15.0 (February 11th, 2024)
useReactToPrint
hook it is now possible to pass the returned callback the content
ref at call time, rather than needing to pass it to the hook directly. This allows for generating the content to be printed closer to when the print occurs. Thanks isocroftdevDependencies
to their latest versions