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

Allow lowercase React import and using an object reference #27

Merged
merged 2 commits into from
Sep 9, 2014
Merged

Allow lowercase React import and using an object reference #27

merged 2 commits into from
Sep 9, 2014

Conversation

zachasme
Copy link
Contributor

@zachasme zachasme commented Sep 9, 2014

I have been importing React into a lowercase variable, and also using the harmony transform for using class syntax:

var react = require('react');

class ComponentName {
  render() {
    ...
  }
}

module.exports = react.createComponent(ComponentName.prototype);

both of which caused the HMR to not work. This commit allows both of these things to also work.

@gaearon
Copy link
Owner

gaearon commented Sep 9, 2014

I think using lowercase react is somewhat unusual but I'm not opposed to it.

However the reason I use ({ is to avoid hot loader choking on its own JS files (which have .createClass(something) calls. It's not ideal but we need to find a different workaround for this issue (#17).

@zachasme
Copy link
Contributor Author

zachasme commented Sep 9, 2014

I tried reproducing the problem in #17 by running the hot loader on both js and jsx files.

This did indeed choke on the React.createClass call in makeComponentUpdater.js (though throwing a different runtime error).

I'm going to wrap the call in parentheses in my fork (3c236aa) though there is probably a more elegant solution.

Incredible loader by the way!

@gaearon
Copy link
Owner

gaearon commented Sep 9, 2014

This looks good. Let's have this merged and see if it causes issues for anyone.

gaearon added a commit that referenced this pull request Sep 9, 2014
Allow lowercase React import and using an object reference
@gaearon gaearon merged commit c41661d into gaearon:master Sep 9, 2014
@gaearon
Copy link
Owner

gaearon commented Sep 9, 2014

Published to NPM as react-hot-loader@0.4.3

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

Successfully merging this pull request may close these issues.

None yet

2 participants