-
Notifications
You must be signed in to change notification settings - Fork 62
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
Async component won't hot-reload #14
Comments
As a temporary workaround it started working when I replaced
with the following:
(EDIT: This workaround is not recommended and will cause rendering issues) Any idea why it wasn't working when I had the code for createAsyncComponent in its own file? |
Experiencing the same issue myself. |
Ooops. The fix would be problematic as it recreates the binding for each render. I don't think that would be a good idea. |
@swernerx I noticed that as well when I tried it and saw that the component was being lazy loaded again and again. @ctrlplusb could this be a bug or an implementation issue? |
Woops, replied on the wrong thread. To be honest I expect RHL will give us issues but so far my personal experience has been okay. It would be good to document where and when the hot reloading stops. Falling back to standard webpack hot reloading is more reliable, but you sacrifice state maintenance. |
Yep, agreed with @swernerx - that workaround is not recommended. Your component will always be lazy loaded which could lead to render flashing. |
Thanks, I edited my comment with a warning. Hopefully a real solution can be found. |
Hi folks, I'm experiencing the same. I'm working in a I just updated from code-split-component and left most of the rest of the app alone. I've followed the approach recommended in the README but I have the same issue as above - HMR logs in console with no actual updates. |
There was an issue with HMR 3 but that has been fixed now gaearon/react-hot-loader#303 - is that what you are seeing? |
All, I am almost done with This should land within a few days. |
It works great for me with react-hot-loader and current or alpha version of react-async-component. import 'babel-core/register';
import 'babel-polyfill';
import FastClick from 'fastclick';
import React from 'react';
import {render} from 'react-dom';
import {createRenderer} from 'fela';
import {Provider} from 'react-fela';
import {AsyncComponentProvider} from 'react-async-component';
import injectTapEventPlugin from 'react-tap-event-plugin';
import {AppContainer} from 'react-hot-loader';
import Root from './app/Root/index';
import configureStore from './app/configureStore/index';
const store = configureStore();
FastClick.attach(document.body);
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
const root = document.getElementById('root');
const renderer = createRenderer();
const mountNode = document.getElementById('stylesheet');
const app = <AsyncComponentProvider>
<Provider renderer={renderer} mountNode={mountNode}>
<Root {...{store}} />
</Provider>
</AsyncComponentProvider>;
const renderHotApp = (RootElement) => {
render(<AppContainer key={Math.random()}>
<AsyncComponentProvider>
<Provider renderer={renderer} mountNode={mountNode}>
<RootElement {...{store}} />
</Provider>
</AsyncComponentProvider>
</AppContainer>, root);
};
if (process.env.NODE_ENV !== 'production') {
if (module.hot) {
module.hot.accept('./app/Root/index', () =>
System.import('./app/Root/index').then(module =>
renderHotApp(module.default),
),
);
}
renderHotApp(Root);
}
else {
render(app, root);
} Note that I use: <AppContainer key={Math.random()}> Otherwise, the async-ed components are not loaded. |
Hey all; React hot loader works with alpha-2 release 🎉 I'll be updating the |
Hey @ctrlplusb I've just tested the alpha-2 release, it is the same for my settings. <AppContainer key={Math.random()}> Is this normal? |
Hmmm, no that shouldn't be the case, but RHL can be very fidgety to get working, and there are definitely some cases where it won't work at all. Take a look at my starter kit for an example of how I set it up. I have it hot reloading in there pretty well. 👍 |
Thank you @ctrlplusb But I used one of your file which is very clever My new setup is now simplier: /* globals document */
import 'babel-core/register';
import 'babel-polyfill';
import FastClick from 'fastclick';
import React from 'react';
import {render} from 'react-dom';
import {createRenderer} from 'fela';
import {Provider as FelaProvider} from 'react-fela';
import {AsyncComponentProvider} from 'react-async-component';
import injectTapEventPlugin from 'react-tap-event-plugin';
import ReactHotLoader from './ReactHotLoader';
import Root from './app/Root/index';
import configureStore from './app/configureStore/index';
const store = configureStore();
FastClick.attach(document.body);
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
const root = document.getElementById('root');
const renderer = createRenderer();
const mountNode = document.getElementById('stylesheet');
const renderApp = RootElement => {
const app = <ReactHotLoader key={Math.random()}>
<AsyncComponentProvider>
<FelaProvider renderer={renderer} mountNode={mountNode}>
<RootElement {...{store}} />
</FelaProvider>
</AsyncComponentProvider>
</ReactHotLoader>;
render(app, root);
};
if (process.env.NODE_ENV !== 'production' && module.hot) {
module.hot.accept('./app/Root/index', () =>
System.import('./app/Root/index').then(module => renderApp(module.default)),
);
}
renderApp(Root); My RootElement includes the Router because it is different when I'm in dev or prod environment ;) |
I still need to put: |
I also need to use |
Fyi, connected components only reloading every other change is no longer an issue with react-hot-loader 4 beta 7. |
I moved my app from code-split-component to react-async-component but the Async components don't seem to hot reload properly. When I make a change to an Async component I get the usual messages in Chrome console with no differences ([HMR].. ) however the displayed content doesn't change. If I change an Async component then also change a non-async component, the changes to both appear at the same time.
Relevant section of App.jsx:
AppContent.jsx:
IntroductionAsync.jsx:
The problem occurs when I try to edit Introduction.jsx.
[email protected]
[email protected]
[email protected]
Is there something I'm doing wrong or is this a bug of some sort?
The text was updated successfully, but these errors were encountered: