0.1.8 • Published 6 years ago

react-print-component v0.1.8

Weekly downloads
50
License
MIT
Repository
-
Last release
6 years ago

React Print Component

Print your component!

Arguments

NameTypeDefaultDescription
singlePagebooleanAdd a react-print-single class to print <div>

Example Usage

  1. Add <PrintComponent /> Element to your root element

    ...
    
    render() {
        return (
            <div>
                <PrintComponent />
                <div className="main-root"></div>
            </div>
        );
    }
    
    ...
  2. Use static functions to print your components.

    import PrintComponent from 'react-print-component';
    
    export class TestComponent() {
    
        ...
    
        onPrintButtonClick() {
            //Replace components added
            PrintComponent.SetPrintContent(this.render());
            //Add components to list
            PrintComponent.AddPrintContent(this.render());
            PrintComponent.AddPrintContent(<div>{"Mulit element"}</div>);
            //Clear all added components in list
            PrintComponent.ClearComponent();
            ...
            do something
            ...
    
            //Call this method to print
            PrintComponent.Print();
        }
    
        ...
    }
  3. Write print style in @media

        @media print {
            
            ...
            
            h1 {}
            h2 {}
            button {}
            input[type=text] {}
    
            ...
        }
0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago