Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default function Home() {
- const [isPrint, setIsPrint] = useState(false)
- const handlePrint = () => {
- setIsPrint(!isPrint)
- setTimeout(() => {
- window.print()
- }, 500)
- }
- return (
- <div>
- <button onClick={handlePrint}>Print</button>
- <div
- id="print"
- className={`${isPrint ? 'block' : 'hidden'}`}
- dangerouslySetInnerHTML={{ __html: html }}
- ></div>
- </div>
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement