-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Matt Herbst <[email protected]>
- Loading branch information
1 parent
b2b239f
commit 18b27d9
Showing
38 changed files
with
1,574 additions
and
1,937 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.