gregnb / use-detect-print

A react hook to detect when a page is being printed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use-detect-print

React Hook to detect printing

Installation

npm install use-detect-print --save

Usage

import React from 'react';
import useDetectPrint from 'use-detect-print';

function App() {

  const isPrinting = useDetectPrint();

  return (
    <div>
     <span>Is it printing? </span>      
     {isPrinting ? (
       <span style={{ color: 'green', fontSize: 50 }}>Yes</span>
     ): (
       <span style={{ color: 'red' }}>No!</span>
     )}
    </div>
  );
}

About

A react hook to detect when a page is being printed


Languages

Language:JavaScript 88.1%Language:HTML 11.9%