Skip to content

Commit

Permalink
Add callbacks on document/page error
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Nov 11, 2016
1 parent efb7186 commit 39abedc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/react-pdf.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ export default class ReactPDF extends Component {
}

onDocumentError = () => {
if (
this.props.onDocumentError &&
typeof this.props.onDocumentError === 'function'
) {
this.props.onDocumentError();
}

this.setState({ pdf: false });
}

Expand All @@ -72,6 +79,13 @@ export default class ReactPDF extends Component {
}

onPageError = () => {
if (
this.props.onPageError &&
typeof this.props.onPageError === 'function'
) {
this.props.onPageError();
}

this.setState({ page: false });
}

Expand Down Expand Up @@ -200,7 +214,9 @@ ReactPDF.propTypes = {
error: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
file: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
loading: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
onDocumentError: PropTypes.func,
onDocumentLoad: PropTypes.func,
onPageError: PropTypes.func,
onPageLoad: PropTypes.func,
onPageRender: PropTypes.func,
pageIndex: PropTypes.number,
Expand Down

0 comments on commit 39abedc

Please sign in to comment.