react-to-print
Advanced tools
Changelog
2.8.0 (May 19th, 2020)
FEATURE 245: documentTitle
prop can now be passed to set a default filename when the user is saving as a PDF. Thanks zb2oby
FEATURE 244: trigger
is now an optional prop. To print without it we now offer two new options.
PrintContextConsumer
with a render-props pattern:
import { PrintContextConsumer } from 'react-to-print';
<ReactToPrint content={() => this.componentRef}>
<PrintContextConsumer>
{({ handlePrint }) => <button onClick={handlePrint}>Print this out!</button>}
</PrintContextConsumer>
</ReactToPrint>
useReactToPrint
for hook-based printing
import { useReactToPrint } from 'react-to-print';
const Example = () => {
const componentRef = useRef();
const handlePrint = useReactToPrint({ content: () => componentRef.current });
return (
<div>
<ComponentToPrint ref={componentRef} />
<button onClick={handlePrint}>Print this out!</button>
</div>
);
};
Huge thanks to vtsybulin for these fantastic additions.
CHORE: upgrade devDependencies
to latest
Changelog
2.7.0 (May 1st, 2020)
pageStyle
prop can now be passed as a function. Thanks sergeyshmakovtarget.contentWindow.print
devDependencies
to latestbrowserslist
best practicesChangelog
2.5.1 (January 9th, 2020)
CHORE 208 Minor improvements to code comments, linting, and README
CHORE 207 Updated devDependencies
FIX 204: Ensure images are fully loaded before printing. Previously long-loading images might not be included in the print. This ensures that we wait for them to load, similar to how we wait for style sheets to load. Thanks nhanhuynh-agilityio