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

Uncaught ReferenceError: _this3 is not defined #928

Closed
EmpireJones opened this issue Apr 6, 2018 · 2 comments
Closed

Uncaught ReferenceError: _this3 is not defined #928

EmpireJones opened this issue Apr 6, 2018 · 2 comments

Comments

@EmpireJones
Copy link

If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.

Description

What you are reporting:
When I modify some components, I get:
Uncaught ReferenceError: _this3 is not defined

Looking at the code which is running:

(function REACT_HOT_LOADER_SANDBOX () {
          var _this = this; // common babel transpile
          var _this2 = this; // common babel transpile
          return function (props) {
		// cancel existing requests
		_this3.state.doFetchStopper && _this3.state.doFetchStopper.stop();

I agree that it looks like _this3 doesn't exist.

Based on the code in /src/proxy/inject.js, _this2 is called out explicitly; should _this3 be there too?

This seems related: babel/babel#4550
Which references this: #391
but that issues says that it's fixed in 4.0.0 (I'm using 4.0.1 of react-hot-loader).

Expected behavior

What you think should happen:
_this3 should exist?

Actual behavior

What actually happens:

_this3 doesn't exist

Environment

React Hot Loader version:

Run these commands in the project folder and fill in their results:

  1. node -v: v9.10.1
  2. npm -v: 5.6.0

Then, specify:

  1. Operating system: Ubuntu 17.10
  2. Browser and version: 65.0.3325.181 (Official Build) (64-bit)
@theKashey
Copy link
Collaborator

It is not easy to properly fix this, and the best way is to transpile code not into es5, but to es6. Ie keep arrow functions arrow.
(but I will add _this3)

@EmpireJones
Copy link
Author

@theKashey - awesome, thanks! I can confirm that building without the code transpiled for older browsers fixes it. I'd prefer to have my development setup mirror production, so this change will be helpful.
Thanks again!

theKashey added a commit that referenced this issue Apr 18, 2018
adding _this3 to handle babel edge cases. fixes #928
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants