Comments (7)
@yantakus, since you are using Next.Js, try using some strategy regarding NoSSR components. For example: https://nextjs.org/docs#with-no-ssr.
from react-to-pdf.
@yantakus, since you are using Next.Js, try using some strategy regarding NoSSR components. For example: https://nextjs.org/docs#with-no-ssr.
@ivmarcos next team update their page, on nowadays this kind of info is located here:
https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr
from react-to-pdf.
Are you using React on server or front end?
from react-to-pdf.
I'm importing it into a React project. Let me know if there are any other questions I can answer.
from react-to-pdf.
Hi @TonyBrobston! This type of error related to the message window is not defined
happens when you are using on the server side (node) and not in the browser. That's why I asked if you were using React on the server, because this lib is intended to be used only in the browser, SSR is not supported, sorry.
from react-to-pdf.
I don't need it to render server side, but in my case I'm using next.js and the app is rendered initially at server. I thought I can do smth like this:
{process.browser && (
<ReactToPdf>
{({toPdf, targetRef}) => (
<div style={{width: 500, height: 500, background: 'red'}} onClick={toPdf} ref={targetRef}/>
)}
</ReactToPdf>
)}
but it's not possible, because I'm getting window is not defined
even when I'm just importing the library and not using it.
Why not doing something like this
if (window) {
...
}
before using it?
from react-to-pdf.
As @ltakato said, you will not have this problem when you use dynamic import.
Example:
import dynamic from 'next/dynamic'
const ReactToPdf = dynamic(() => import('react-to-pdf'), { ssr: false })
from react-to-pdf.
Related Issues (20)
- Bottom of page content is cut off in PDF HOT 3
- Black pages PDF file download after 10 pages HOT 2
- Conditionally render an element HOT 2
- GeneratePdf doesn't download the file in Mac Safari browser
- Page Orientation does not work in toPDF Hook HOT 1
- Table with rowSpan >2 was hidden half border when export
- I am trying to print my form which has an HTML5 date picker, even if the format is dd-mm-yyyy after i initiate the print, the date is coming in reverse order, i.e., yyyy-mm-dd.
- Existing Issue: Images don't render properly HOT 2
- Text is breaking when it goes to new page HOT 2
- Line cutoff between pages HOT 3
- how to change size of page HOT 1
- The HTML was cut in overlapping between pages without any option to manage it; any idea?
- Need a base64 instead of save
- Browser crashing on pdf generation and line cut off HOT 1
- problem with loader HOT 1
- How do you control page breaks?
- How do I repeat header and footer on ech page?
- 2 Pages showing in the downloaded PDF(unwanted 2nd page) HOT 1
- Print hidden elements
- How Can i remove the white area in bottom of the page and make the page 100% fully
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-to-pdf.