use-detect-print

gregnb
esm
use-detect-print JS library on GitHub use-detect-print JS library on npm Download use-detect-print JS library

A custom hook to detect printing in the browser

Version 0.0.2 License MIT
use-detect-print has no homepage
use-detect-print JS library on GitHub
use-detect-print JS library on npm
Download use-detect-print JS library
Keywords
react-hookshooksreactprintuse-detect-print

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>
  );
}