Git Product home page Git Product logo

Comments (14)

codelegant avatar codelegant commented on September 27, 2024 1

@gaearon In product env, use externals, and the addons had to declare like this const update=React.addons.update. But in dev env, use NPM package, you should import update from 'react-addons-update.
That made me confused, for consistency, I had to use externals in dev.
Is there any solution? I'm waiting online. Thank you.

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Good catch. We depend on internal react/lib/ReactMount.

In your case, it seems that external packages are being used for React itself, but react/lib/ReactMount is taken from NPM package. This doesn't work because they correspond to two independent copies of React. If you delete NPM packages, it should no longer build at all.

I think it would be nice to avoid depending on ReactMount but then we'd need another way to get list of root instances. This could be made injectable by user but I'm not sure if it's worth the complexity.

What practical benefit does it give you to use externals in dev?

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Please see if this works for you:

https://github.com/gaearon/react-hot-loader/blob/master/docs/README.md#usage-with-external-react

Available in 1.0.6.

from react-hot-loader.

bjfletcher avatar bjfletcher commented on September 27, 2024

Hello @gaearon! That's a great turnaround. :)

A reason for asking about this is because, for me, If there's any way to reduce the differences between development and production environments without impacting on their productivity and performance respectively, then I feel that's worth exploring. :)

I wonder if Facebook or the React people have been asked about providing some way of accessing ReactMount with the precompiled version? Worth asking them, do you think?

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

As they're aiming for smaller API surface I doubt they'd be inclined to do it.

There is a devtools hook that can be used to get internal objects (React Chrome DevTools uses it), however this hook is meant to only be set once so it's inconvenient and error-prone to try to use it here. I'll raise an issue though.

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Filed as facebook/react#2797

from react-hot-loader.

frankychung avatar frankychung commented on September 27, 2024

Just wanted to chime in this works great for our project that has React as an external. Thank you!

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

@frankychung I'm glad to hear this!

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Davide, can’t find your comment, have you figured it out, or is Github glitching?

On 03 Feb 2015, at 10:34 , Davide [email protected] wrote:

I think this happens even if you use react from npm and you require('react/addons') which is the version with all the addons.
At least it happens to me with react 0.11.1


Reply to this email directly or view it on GitHub #53 (comment).

from react-hot-loader.

davibe avatar davibe commented on September 27, 2024

I had a second look. Basically I wanted to require react+addons without modifying my code (its code that works fine with plain require.js and now i am making it work with webpack too). So i set up an alias { 'react': 'react/addons' } in webpack.config.js but if you do that then again react-hot-loader can't find 'react/lib/ReactMount' anymore. Which makes sense. It's just one more case similar to the previous ones.

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

Yeah I also bumped into that before. You can actually work around it in a terrible-ish way:

'react': 'react/addons',
// A workaround for react/lib to be resolved correctly:
'react/addons/lib': 'react/../lib',

from react-hot-loader.

davibe avatar davibe commented on September 27, 2024

ahaha, my god. I like the hot realoding thing. Its why i am tryin webpack. But the amount of unclean hacks I had to apply is making me sick. Thank you though, nice one.

from react-hot-loader.

gaearon avatar gaearon commented on September 27, 2024

With [email protected] you'll no longer need this Injection nonsense, it will just work.
Please provide any feedback on it in this PR: #182

from react-hot-loader.

gioacostax avatar gioacostax commented on September 27, 2024

@gaearon but now appears this; if I use ReactDOM to render (the correct way):

ERROR in ./~/react-dom/index.js
/bower_components/react/react.min.js/lib/ReactDOM

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.