report this guy he uses hacks and he was being toxic. How can I flush the output of the print function? I will be demonstrating how you can print using the React-To-Print and even hide the component being printed while maintaining the CSS styles. For further actions, you may consider blocking this person and/or reporting abuse. When rendering multiple components to print, for example, if you have a list of charts and want each chart to have its own print icon, ideally you will wrap each component to print + print button in its own component, and just render a list of those components. react-to-print can be used for printing in Electron, but you will need to provide your own print method since Electron does not natively support the window.print method. For example: ".divider { break-after: always; }". Below the ReactToPrint component is the component to be printed with a ref connecting it to the ReactToPrint content props. Once unsuspended, ebereplenty will be able to comment and publish posts again. I am unable to force page break. verso This package aims to solve that by popping up a print window with CSS styles copied over as well. See 248 for an example. ReactToPrint-React React CSS npm install --. Do NOT pass an `onClick` prop. Please see this answer on StackOverflow for how to do this. Print React components in the browser. All react-to-print is able to do is open the dialog and give it the desired content to print. // Do whatever you want here, including asynchronous work, // We store the resolve Promise being used in `onBeforeGetContent` here, // We watch for the state to change here, and for the Promise resolve to be available, // Resolves the Promise, letting `react-to-print` know that the DOM updates are completed, // Reset the Promise resolve so we can print again, /* Use 100% here to support printing more than a single page*/, One or more class names to pass to the print window, separated by spaces, A function that returns a component reference value. To modify content before printing, use, Callback function (signature: `function(errorLocation: 'onBeforePrint', We set some basic styles to help improve page printing. Either returns void or a Promise. How do I refresh a page using JavaScript? s with empty href attributes are INVALID HTML. Always insert a page-break after a