ReactPDF.render is not a function
See original GitHub issueOS: 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
react-pdf/renderer on production gives an error this.subset ...
@react-pdf/renderer on production gives an error this.subset.encodeStream is not a function · javascript · reactjs · typescript · pdf · webpack.
Read more >react-pdf - npm
A prop that behaves like ref, but it's passed to main <div> rendered by <Document> component. n/a. Function: (ref) => { this.myDocument =...
Read more >Options - React PDF Viewer
`renderLoader`, `Function`, The loader renderer, 2.0.0 ... If it's not set, the initial zoom level will be calculated based on the dimesion of...
Read more >Page wrapping - React-pdf
If that's not what you need, you can disable this very easily by doing: import { Document, Page } from '@react-pdf/renderer' const doc...
Read more >document.getElementById(...).render is not a function - React.js
I wasted again another hour of my life finding this solution.
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
Hey. If you read the README you will see that ReactPDF.render is the mounter function for generating documents using Node (server-side). You’re using the lib in a web environment. There’s an open issue about generating documents on the fly. It’s not something completely solved, but please refer to it
@diegomura
README
says thatReactPDF.render
only “Save in a file”. I usedresume
example and replacereact-pdf.es.js
to@react-pdf/renderer
. And I usedReactDOM.render(<MyDocument />, document.getElementById('root'));
for client side.However it shows just text…