mikecousins/react-pdf-js

Add a check at the point that the PDF will be drawn

Closed this issue · 1 comments

Scenario:
User navigates away from page before PDF has loaded. The drawPDF callback triggers but the canvas element is no longer rendering.

Error:
TypeError: Cannot read property 'getContext' of null

Source:

const canvasContext = canvas.getContext('2d');

Proposed solution:
add a simple check before getContext is called.

turns out my code is out of date....