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

Hot reloading resources outside of React (server rendering) #340

Closed
mridgway opened this issue Jul 27, 2015 · 7 comments
Closed

Hot reloading resources outside of React (server rendering) #340

mridgway opened this issue Jul 27, 2015 · 7 comments

Comments

@mridgway
Copy link

The examples that show hot reloading of reducers depend on the redux instance being instantiated within a React component. This works for client-only apps, but when you use server-rendering, you need to bootstrap the application and its state prior to calling React.render. Many of the isomorphic examples I've looked at do not work with hot reloading because the reducers are required from a client bootstrap file instead of the top-level app component. It seems like there would have to be some module.hot magic for hot reloading within server-rendered apps.

@gaearon
Copy link
Contributor

gaearon commented Jul 27, 2015

Might be related: #301

@gaearon gaearon added this to the 1.0 milestone Jul 27, 2015
@gaearon
Copy link
Contributor

gaearon commented Jul 27, 2015

I think we want to understand how to do this before 1.0 is shipped.

@wmertens
Copy link
Contributor

@mridgway cool I never considered server side hot reloading! Do you have a code example?

@mridgway
Copy link
Author

@wmertens This isn't server-side hot reloading. The client bootstrapping code has to be moved outside of React when rendering on top of existing markup vs. rendering fully on the client.

@gaearon
Copy link
Contributor

gaearon commented Jul 29, 2015

@mridgway

Does something like

import * as reducers from './reducers';

// ...

let store = createStore(combineReducers(reducers));

// ...

React.render(<Stuff />, ...);

if (module.hot) {
  module.hot.accept('./reducers', function () {
    store.replaceReducer(combineReducers(reducers));
  });
}

work?

@gaearon
Copy link
Contributor

gaearon commented Jul 31, 2015

Let's continue the discussion in #350.

@gaearon
Copy link
Contributor

gaearon commented Aug 31, 2015

Now we encourage people to use hot module replacement API directly, so that you have full control: #667

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants