Blank sheet error react to print
See original GitHub issueHi everyone, I have a problem that has already been with me for two days. I’m using pure functional components, I found the following example, but when I press the button, I only get a blank sheet in the print preview, I tried to do it with classes, but it doesn’t give me either, I don’t know if I’m doing something wrong , all this in React JS, my files have a .jsx extension, I’m not sure what the problem is, I’ve already looked for too many solutions and I can’t find what I’m doing wrong, thanks.
I’m using: “react”: “^ 16.8.6”, “react-to-print”: “^ 2.13.0”
import React, { useRef } from "react";
import ReactToPrint from "react-to-print";
const ComponentToPrint = React.forwardRef((props, ref) => (
<table ref={ref}>
<thead>
<th>column 1</th>
<th>column 2</th>
<th>column 3</th>
</thead>
<tbody>
<tr>
<td>data 1</td>
<td>data 2</td>
<td>data 3</td>
</tr>
<tr>
<td>data 1</td>
<td>data 2</td>
<td>data 3</td>
</tr>
<tr>
<td>data 1</td>
<td>data 2</td>
<td>data 3</td>
</tr>
</tbody>
</table>
));
const Example = () => {
const componentRef = useRef();
return (
<div>
<ReactToPrint
trigger={() => <a href="#">Print this out!</a>}
content={() => componentRef.current}
/>
<ComponentToPrint ref={componentRef} />
</div>
);
}
export default Example;
Issue Analytics
- State:
- Created 2 years ago
- Comments:15
Top Results From Across the Web
React to Print is showing blank page in React JS
I am trying to add the print feature on a div's content. But the Print VIewer is showing a blank White page. This...
Read more >react-to-print - npm
Start using react-to-print in your project by running `npm i ... This can be used to change the content on the page before...
Read more >Fix printing problems in Firefox - Mozilla Support
Learn how to troubleshoot and fix printing problems in Firefox. ... Check to see whether the page prints correctly in another browser (such...
Read more >React Without JSX
Using React without JSX is especially convenient when you don't want to set up compilation in your build environment. Each JSX element is...
Read more >ReactJS web app renders blank page on iPhone
Hi, I used npm create-react-app to make a web app with firebase backend accessing it through redux-firebase. The web app functions normally on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same issue here, The only way I can see something in the print preview is by setting
copyStyles={false}
which gives an ugly rendering of my content.Edit:
I had an import of a specifc css file in my js file. By removing that import it started working properly.
i’m still experiencing this issue, is anyone had an update to this? my code looks exactly like @lizarragadev . Thanks in advance.
Update 2 hours after i commented this : turns out mine is already showed, but because of my component is white text, it shows a blank preview which is actually there is text on it with white color. so i add copyStyles={false} prop to negate the css