Skip to content

Commit

Permalink
Fix babelHelpers.typeof is not a function
Browse files Browse the repository at this point in the history
Summary:
We started encountering the error described in #5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook/react-native#5747 (comment)) led to [this comment](facebook/react-native#4844 (comment)) 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 facebook/react-native#11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
  • Loading branch information
cmcewen authored and facebook-github-bot committed Dec 20, 2016
1 parent 79e12e5 commit 771606f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions react-packager/src/Resolver/polyfills/babelHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 771606f

Please sign in to comment.