Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native Incompatibility: TypeError: (0 , _getPrototypeOf2.default) is not a function #699

Open
EtDu opened this issue Apr 27, 2021 · 3 comments
Labels
kriskowal-reviewed-2024-01 Issues that kriskowal is satisfied do not need attention from team bug review as of January, 2024

Comments

@EtDu
Copy link

EtDu commented Apr 27, 2021

Console Error:

TypeError: (0 , _getPrototypeOf2.default) is not a function

In the Javascript bundle:

var _getPrototypeOf2 = _$$_REQUIRE(_dependencyMap[0], "@babel/runtime/helpers/interopRequireDefault")(_$$_REQUIRE(_dependencyMap[6], "@babel/runtime/helpers/getPrototypeOf"));

if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;

Corresponding Source @babel/runtime/helpers/getPrototypeOf :

function _getPrototypeOf(o) {
  module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
    return o.__proto__ || Object.getPrototypeOf(o);
  };
  module.exports["default"] = module.exports, module.exports.__esModule = true;
  return _getPrototypeOf(o);
}

module.exports = _getPrototypeOf;
module.exports["default"] = module.exports, module.exports.__esModule = true;

It seems that getPrototypeOf2.default is undefined in this case. Perhaps because of this phase during lockdown():

Removing intrinsics.Object.getPrototypeOf.default
@EtDu
Copy link
Author

EtDu commented Apr 27, 2021

Fixed by removing
module.exports["default"] = module.exports, module.exports.__esModule = true;

@EtDu
Copy link
Author

EtDu commented Apr 27, 2021

Next is TypeError: (0 , _get2.default) is not a function
also fixed by removing
module.exports["default"] = module.exports, module.exports.__esModule = true;
in @babel/runtime/helpers/get

@bentobox19
Copy link
Contributor

Since this is solved by patching a babel library (see below), Suggest closing this issue, @kriskowal.

diff --git a/node_modules/@babel/runtime/helpers/extends.js b/node_modules/@babel/runtime/helpers/extends.js
index eaf9547..a481fbb 100644
--- a/node_modules/@babel/runtime/helpers/extends.js
+++ b/node_modules/@babel/runtime/helpers/extends.js
@@ -1,5 +1,5 @@
 function _extends() {
-  module.exports = _extends = Object.assign || function (target) {
+  module.exports = _extends = function (target) {
     for (var i = 1; i < arguments.length; i++) {
       var source = arguments[i];

diff --git a/node_modules/@babel/runtime/helpers/getPrototypeOf.js b/node_modules/@babel/runtime/helpers/getPrototypeOf.js
index a6916eb..9f92ea5 100644
--- a/node_modules/@babel/runtime/helpers/getPrototypeOf.js
+++ b/node_modules/@babel/runtime/helpers/getPrototypeOf.js
@@ -1,5 +1,5 @@
 function _getPrototypeOf(o) {
-  module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
+  module.exports = _getPrototypeOf = function _getPrototypeOf(o) {
     return o.__proto__ || Object.getPrototypeOf(o);
   };
   module.exports["default"] = module.exports, module.exports.__esModule = true;

@kriskowal kriskowal added the kriskowal-reviewed-2024-01 Issues that kriskowal is satisfied do not need attention from team bug review as of January, 2024 label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kriskowal-reviewed-2024-01 Issues that kriskowal is satisfied do not need attention from team bug review as of January, 2024
Projects
None yet
Development

No branches or pull requests

3 participants