anorudes / redux-easy-boilerplate

React redux easy boilerplate
MIT License
633 stars 123 forks source link

Hot Reloading Not Working #7

Closed mindjuice closed 8 years ago

mindjuice commented 8 years ago

Thanks for the nice boilerplate.

When I change .js files though (e.g., src/components/Header/index.js), the browser doesn't hot reload them. I get the following error in the JS console.

[HMR] The following modules couldn't be hot updated: (They would need a full reload!) bundle.js [HMR] - 256

I found this page that mentions the error, but I don't see how the described cause applies:

Any idea why this happens? Does it work for you?

anorudes commented 8 years ago

Maybe it happens when you changed stateless function components. Will try replace

export const Header = () => (
  <div className={`${styles}`}>
    Redux easy boilerplate
  </div>
);

on

export class Header extends Component {
  render() {
    return (
      <div className={`${styles}`}>
        Redux easy boilerplate
      </div>
    );
  }
}

I saw this problem last, don't know how to resolve this.

anorudes commented 8 years ago

You right! It happens when tried to changed Header component, but Home and List worked. I'' try to fix this in next commit.

If replace "stateless function" with "class" the problem will resolve:

import React, { Component } from 'react';

/* component styles */
import styles from './styles';

export class Header extends Component {
  render() {
    return(
      <div className={`${styles}`}>
        Redux easy boilerplate
      </div>
    );
  }
}
mindjuice commented 8 years ago

Ah...I see. Wonder if this can be fixed in the hot reload code instead so that we can use those types of functions?

mindjuice commented 8 years ago

See here: https://github.com/gaearon/react-hot-loader/issues/145

anorudes commented 8 years ago

Don't know, I tryied to find the solution all last night. Love "stateless function" but it doesn't work with hot-reload and react-transform (see 2 branch)

mindjuice commented 8 years ago

Thanks for the help. I'll switch to normal components for now.

anorudes commented 8 years ago

I don't know why but the Header and the Footeer don't work with hot-reload. All others containers ("List", "Home") working and they are stateless function too. Maybe it'is bug hot reload library or maybe need to fix the code boilerplate. Don't saw "stateless function" components in others boilerplate :(

mindjuice commented 8 years ago

So what do you think? Should the boilerplate be changed to use normal components until hot reloading is working? Or just mention it as a caveat in the docs?

anorudes commented 8 years ago

I think "normal component" because we don't know how to fix bug with "stateless function" I don't have any time today :( If you want you'll can make new pull request for this task. Thanks :)

anorudes commented 8 years ago

I'll fix this problem with next commit. Also will merge with "react-transform" branch :)

anorudes commented 8 years ago

It's ok now. And i replaced hot-reload with react-transform for catch errors in the browser :)

mindjuice commented 8 years ago

Sorry...I was busy and didn't get a chance to work on this. Thanks for the fix!

anorudes commented 8 years ago

Thanks to you for issue and like the boilerplate :) :+1: