OS:
macOS High Sierra v.10.13.6
React-pdf version:
1.0.0-alpha.14
Description:
When I am trying to render the ReactPDF in the componentWillMount I am getting the error __WEBPACK_IMPORTED_MODULE_1__react_pdf_renderer__.f.render is not a function. Below is the full code snippet. My goal is to download a version of the PDF on the mounting of a page and show a loading screen to the user. Please let me know if anyone has faced this issue or knows the solution! Cheers!
import React, { Component } from 'react'
import ReactPDF, { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer'
import autobind from 'react-autobind'
class Container extends Component {
constructor (props) {
super(props)
this.state = {
demographics: [],
isDataLoaded: false,
}
autobind(this)
}
componentWillMount () {
ReactPDF.render(<MyDocument />, `${__dirname}/example.pdf`)
}
render () {
return (
<Main />
)
}
}
// Create styles
const styles = StyleSheet.create({
page: {
flexDirection: 'row',
backgroundColor: '#E4E4E4',
},
section: {
margin: 10,
padding: 10,
flexGrow: 1,
}
})
// Create Document Component
const MyDocument = () => (
<Document>
<Page size="A4" style={styles.page}>
<View style={styles.section}>
<Text>Section #1</Text>
</View>
<View style={styles.section}>
<Text>Section #2</Text>
</View>
</Page>
</Document>
)
const Main = () => (
<div>loading pdf</div>
)
export default Container
Hey.
If you read the README you will see that ReactPDF.render is the mounter function for generating documents using Node (server-side). You鈥檙e using the lib in a web environment.
There鈥檚 an open issue about generating documents on the fly. It鈥檚 not something completely solved, but please refer to it
@diegomura
README says that ReactPDF.render only "Save in a file".
I used resume example and replace react-pdf.es.jsto @react-pdf/renderer.
And I used ReactDOM.render(<MyDocument />, document.getElementById('root')); for client side.
However it shows just text..

Hey.
If you read the README you will see that ReactPDF.render is the mounter function for generating documents using Node (server-side). You鈥檙e using the lib in a web environment.
There鈥檚 an open issue about generating documents on the fly. It鈥檚 not something completely solved, but please refer to it
Any updates on this issue?
Yep. Generating docs on the fly has been around for awhile now. Check https://react-pdf.org/advanced#on-the-fly-rendering
Yep. Generating docs on the fly has been around for awhile now. Check https://react-pdf.org/advanced#on-the-fly-rendering
There is some issue when I apply to my react web
import { PDFDownloadLink, Document, Page } from '@react-pdf/renderer'
const MyDoc = () => (<Document><Page>ABC</Page></Document>)
const App = () => (<div><PDFDownloadLink document={<MyDoc />} fileName="somename.pdf">{({ blob, url, loading, error }) => (loading ? 'Loading document...' : 'Download now!')}</PDFDownloadLink</div>)
then inside the react export class:
public render(): React.ReactElement<IJsomProps> {<div>Export</div><div><PDFDownloadLink document={<MyDoc />} fileName="somename.pdf">
{({ blob, url, loading, error }) => (loading ? 'Loading document...' : 'Download now!')}
</PDFDownloadLink></div>}
it gives the error

What issue?
What issue?
I got the error of 'getCurrentStack' of undefined. Please see the above screen capture. Thanks!
Open a new issue with this. Not sure why you posted this here
Most helpful comment
Hey.
If you read the README you will see that ReactPDF.render is the mounter function for generating documents using Node (server-side). You鈥檙e using the lib in a web environment.
There鈥檚 an open issue about generating documents on the fly. It鈥檚 not something completely solved, but please refer to it