Git Product home page Git Product logo

Comments (18)

gaearon avatar gaearon commented on September 27, 2024

I'd like to. Any ideas how to tell class A is still class A in next version of module? Ideally we'd also like to support dynamically generated classes inside function. I can't think of a way to do that now..

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

We can probably differentiate by call index (first createClass in module, second, etc) and disable hot reload for createClass calls after module definition (this will avoid problems with functions). Would you like to try?

from react-hot-loader.

mbektimirov avatar mbektimirov commented on September 27, 2024

I didn't read through all code yet, is it possible to simply check for an id property and create it if necessary?

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Ah, I see now, your use case is createClass inside a function. Same as #24.

React does not support setting displayName property directly into wrapped component

Um, you're sure? I thought it worked.. Is it true for 0.11? So you can't do

  return React.createClass({
    displayName: displayName,

?

That's weird...

from react-hot-loader.

mbektimirov avatar mbektimirov commented on September 27, 2024

That's right, this problem is actual for 0.11. Same issue with Om: omcljs/om#124

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

OK, looking into that.

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Why does this work for me?

http://jsbin.com/jaxezekeni/1/edit?html,js,output

/** @jsx React.DOM */

var wrap = function (displayName) {
  return React.createClass({
    displayName: displayName,
    render: function () {
      return <div>{displayName}</div>;
    }
  });
};

var A = wrap('yo');
var B = wrap('dawg');

var X = React.createClass({
  render: function () {
    return <div><A /><br /><B /></div>;
  }
});

React.renderComponent(<X />, document.body);

from react-hot-loader.

mbektimirov avatar mbektimirov commented on September 27, 2024

Maybe the problem is with transferPropsTo?

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Your code works for me too. (Fixed fiddle to use displayName)

from react-hot-loader.

mbektimirov avatar mbektimirov commented on September 27, 2024

It's very strange. I'll investigate it more precisely.

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Are you sure you have 0.11 locally?
Maybe you updated package.json but old dependency is still there.

Om comment is from February so it may not be relevant anymore..

from react-hot-loader.

mbektimirov avatar mbektimirov commented on September 27, 2024

Figured it out. React was loaded twice in a bundle. Thank you for help. I'm closing this issue.

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Woah, that's quite a common problem actually. I wish React warned right away when this happens!

from react-hot-loader.

jedwards1211 avatar jedwards1211 commented on September 27, 2024

I'm having an issue with React being loaded twice, but I don't understand what's causing it to be loaded twice. Do you guys have any tips? I'm using the google-map-react library and this code:

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

Somehow seems to be loading an additional copy of react. Not even different versions! Why would Webpack ever load two copies of the same exact library? Seems like a bug to me

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

@jedwards1211 Those are not two Reacts, it's just the way Babel names variables.

from react-hot-loader.

jedwards1211 avatar jedwards1211 commented on September 27, 2024

@gaearon yes, I understood those aren't two Reacts. I think what was happening though was a second version of React was being loaded from google-map-react's own node_modules, even though its webpack bundle declares react as an external. I still haven't had time to get to the bottom of this issue

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

@jedwards1211 NPM doesn't care what Webpack says. If google-map-react's version of React declared as peerDependency is not compatible with the one in the outer project, NPM will install its own version of React inside there. That's the big problem with NPM 2, and it will be fixed in NPM 3.

from react-hot-loader.

jedwards1211 avatar jedwards1211 commented on September 27, 2024

Huh, it was compatible as far as I know, but that's good to know anyway. Thanks!

from react-hot-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.