You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
react-to-print assumes that the React object has Object.prototype as its prototype, since it calls React.hasOwnProperty() and the hasOwnProperty function only exists on the Object.prototype.
However, this assumption is not true of ES modules, nor of SystemJS modules. The ES module spec says that ES modules must have a prototype of null, which means that they do not have the hasOwnProperty function available on them. This issue has been discussed and fixed in a variety of places, including the following links:
react-to-print assumes that the
React
object hasObject.prototype
as its prototype, since it callsReact.hasOwnProperty()
and thehasOwnProperty
function only exists on the Object.prototype.https://github.com/gregnb/react-to-print/blob/dab3e2224b526f57130615fb977c42359ff10317/src/index.tsx#L4-L5
However, this assumption is not true of ES modules, nor of SystemJS modules. The ES module spec says that ES modules must have a prototype of
null
, which means that they do not have thehasOwnProperty
function available on them. This issue has been discussed and fixed in a variety of places, including the following links:ns
prototype is null, but that breaks some things systemjs/systemjs#2147 (comment)I help maintain SystemJS, and a user reported this error originally with us (see https://single-spa.slack.com/archives/C8R6U7MT7/p1602879935124300).
The following code sandbox shows how the
react-to-print
library dies if provided a React object without Object.prototype as the prototype: https://codesandbox.io/s/blissful-flower-wy5k7?file=/index.htmlThe fix in this case is to call
Object.prototype.hasOwnProperty.call(React, 'useContext')
. I'll submit a PR with that fix.The text was updated successfully, but these errors were encountered: