Skip to content

Commit

Permalink
React 19 Support (#717)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Herbst <[email protected]>
  • Loading branch information
MatthewHerbst and MatthewHerbst authored Jul 15, 2024
1 parent b2b239f commit 18b27d9
Show file tree
Hide file tree
Showing 38 changed files with 1,574 additions and 1,937 deletions.
4 changes: 0 additions & 4 deletions . browserslistrc

This file was deleted.

250 changes: 73 additions & 177 deletions README.md

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions examples/BasicComponent/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as React from 'react';

import { ComponentToPrint } from "../ComponentToPrint";
import { CUSTOM_FONTS } from "../fonts";
import { useReactToPrint } from "../../src/hooks/useReactToPrint";

/**
* A basic printing example printing a component
*/
export const BasicComponent = () => {
const componentRef = React.useRef(null);

const handleAfterPrint = React.useCallback(() => {
console.log("`onAfterPrint` called"); // tslint:disable-line no-console
}, []);

const handleBeforePrint = React.useCallback(() => {
console.log("`onBeforePrint` called"); // tslint:disable-line no-console
return Promise.resolve();
}, []);

const printFn = useReactToPrint({
contentRef: componentRef,
documentTitle: "AwesomeFileName",
fonts: CUSTOM_FONTS,
onAfterPrint: handleAfterPrint,
onBeforePrint: handleBeforePrint,
});

const handleOnClick = React.useCallback(() => {
printFn();
}, [printFn]);

return (
<div>
<button onClick={handleOnClick}>Print</button>
<ComponentToPrint ref={componentRef} />
</div>
);
};
83 changes: 0 additions & 83 deletions examples/ClassComponent/index.tsx

This file was deleted.

79 changes: 0 additions & 79 deletions examples/ClassComponentContextConsumer/index.tsx

This file was deleted.

64 changes: 0 additions & 64 deletions examples/ClassComponentText/index.tsx

This file was deleted.

Loading

0 comments on commit 18b27d9

Please sign in to comment.