react-webpack-generators / react-webpack-template

Simple react webpack template
MIT License
82 stars 44 forks source link

Hot reload not working with React-Router/History API #31

Closed ncksllvn closed 8 years ago

ncksllvn commented 8 years ago

As referenced here, I found the hot update returning 404's with the leading period in the output.publicPath property defined in cfg/base.js when using the History API (specifically, React Router). I don't think this problem is unique to me because I didn't modify the config files.

weblogixx commented 8 years ago

Hi,

still need to investigate on this issue. Could you send me a link to the project you are building?

If this is not possible, at least your routing config may help.

Also I know that some functions (e.g. Flux-Frameworks) will not hold their state on hot reloading. I am currently thinking about removing the react-hot-loader completely.

ncksllvn commented 8 years ago

I love the hot reload feature; just discovered that one issue I was having. My project isn't hosted publicly but here's the summary:

http://localhost:4000/app => http://localhost:8000/assets/8b92334d8f274206dd47.hot-update.json => 200

http://localhost:4000/app/users => http://localhost:8000/app/assets/8b92334d8f274206dd47.hot-update.json => 404

My routes, defined in src/index.js:

 <Provider store={store}>
    <Router history={history}>

      <Route path="login" component={Login}/>
      <Route path="join" component={Join}/>

      <Redirect from="/" to="app"/>

      <Route path="app" component={App}>
        <Route path="users" component={Users}/>
      </Route>

      <Route path="*" component={NoMatch}/>
    </Router>
  </Provider>

I don't know if removing that leading . in the output.publicPath will have other consequences, but I haven't discovered any yet.

weblogixx commented 8 years ago

Hi, it does not seem so. I added it so users are able to use the generator in relative directories. However, this does not play nice with react router subroutes, you are right on that. Mine where also broken as it turned out, I just never noticed it :(. Will move this back (or think about a complete new approach) for the next version. Thank you anyway for your help!