Description
There's a bug in the TypeScript runtime support library (tslib
) that will cause one of the following cryptic errors in a React Native app:
undefined is not an object (evaluating '_globalWindow2['default'].__reactComponentProxies')
Cannot read property '__reactComponentProxies' of undefined
tslib
is utilized by a variety of different popular React Native libraries; for example: lodash-decorators
.
The tslib
maintainers have fixed the issue (in microsoft/tslib#42) but they haven't published a release yet.
The easiest way to work around this issue at present is the following:
-
Identify the packages which depend upon
tslib
by searching youryarn.lock
file fortslib
under thedependencies
section of a dependency.For example, here's how that looks for
lodash-decorators
:
lodash-decorators@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash-decorators/-/lodash-decorators-4.5.0.tgz#a4bb63dfbb512f0dd9409f7af452e4e2edcb80f4"
dependencies:
tslib "^1.7.1"
-
Ensure you're using
yarn
version 1.0 or higher. (Just runyarn
and you'll see your current version.)brew update && brew upgrade yarn
if you're out of date. -
Add a
resolutions
section to yourpackage.json
file for everytslib
dependency you found earlier. The resolution key should be the package with a dependency, followed by/tslib
, and the value is a specific commit on thetslib
repo that contains the fix.For the
lodash-decorators
package, it looks like this:
"resolutions": {
"lodash-decorators/tslib": "Microsoft/tslib#375b3f6"
},
I realize this is not an issue on React Native, so you're welcome to close it. I just wanted to share a workaround in a place where I expect most people will begin searching for this problem after a React Native upgrade.