From ab89b7195d1eea1c096d4134fba3ec517580bbb3 Mon Sep 17 00:00:00 2001 From: Connor McEwen Date: Tue, 20 Dec 2016 15:17:31 -0800 Subject: [PATCH] Fix babelHelpers.typeof is not a function Summary: We started encountering the error described in #5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](https://github.com/facebook/react-native/issues/5747#issuecomment-192356656) led to [this comment](https://github.com/facebook/react-native/issues/4844#issuecomment-191282653) which contains a solution we've been using successfully in our production app. Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize). An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me. Closes https://github.com/facebook/react-native/pull/11093 Differential Revision: D4353977 fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9 --- .../react-packager/src/Resolver/polyfills/babelHelpers.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packager/react-packager/src/Resolver/polyfills/babelHelpers.js b/packager/react-packager/src/Resolver/polyfills/babelHelpers.js index 95b4ba8ad..1390ef6df 100644 --- a/packager/react-packager/src/Resolver/polyfills/babelHelpers.js +++ b/packager/react-packager/src/Resolver/polyfills/babelHelpers.js @@ -19,6 +19,12 @@ var babelHelpers = global.babelHelpers = {}; +babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; + babelHelpers.createRawReactElement = (function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, key, props) {