Comments (14)
@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.
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.
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.
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.
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.
Filed as facebook/react#2797
from react-hot-loader.
Just wanted to chime in this works great for our project that has React as an external. Thank you!
from react-hot-loader.
@frankychung I'm glad to hear this!
from react-hot-loader.
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.
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.
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.
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.
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.
@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)
- React.useEffect's callback will be called when the page is updated HOT 2
- Hot reloading tested in different ways and is not working properly HOT 1
- Sometimes hot() is needed not only for the root component HOT 2
- Hot-Reload fails with “Unexpected token '['. Expected opening '{' at the start of a class body.” HOT 1
- Warning: The final argument passed to useEffect changed size between renders.
- Could not resolve dependency HOT 12
- Not working with react-router-config: Uncaught ReferenceError: module is not defined HOT 9
- Reload Full Page instead of Refresh? HOT 1
- Attempted import error: 'AppContainer' is not exported from 'react-hot-loader'. HOT 1
- document click listener function executed twice: before and AFTER component rendered. HOT 4
- when props include "this"
- How to deal with multiple entries
- in sub project cannot replace in time
- React-hot-loader compatibility with React 16.14.0 HOT 1
- React 18 upgrade HOT 5
- Yarn 3 PNP not compatible
- Regular Expression Denial of Service (ReDoS) HOT 3
- hmr no work in React.PureComponent HOT 2
- Analysis: 98% of dependency updates in this repository can be merged.
- React-Hot-Loader: misconfiguration detected, using production version in non-production environment.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-hot-loader.