Advertisement
metalni

printing

Feb 20th, 2023
1,157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default function Home() {
  2.   const [isPrint, setIsPrint] = useState(false)
  3.  
  4.   const handlePrint = () => {
  5.     setIsPrint(!isPrint)
  6.     setTimeout(() => {
  7.       window.print()
  8.     }, 500)
  9.   }
  10.   return (
  11.     <div>
  12.       <button onClick={handlePrint}>Print</button>
  13.  
  14.       <div
  15.         id="print"
  16.         className={`${isPrint ? 'block' : 'hidden'}`}
  17.         dangerouslySetInnerHTML={{ __html: html }}
  18.       ></div>
  19.     </div>
  20.   )
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement