Skip to content

Hot reloading via react-transform/babel6 is not working when rendering a connected component from a non-connected component #224

Closed
@bunkat

Description

@bunkat

I think this is an issue with how react-redux handles the hot reloading of connected components. If you have a non-connected (dumb) component render a connected component as a wrapper component, any content within that wrapper will no longer be re-rendered on change.

_Connected component:_

class Form extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <form>
        {this.props.children}
      </form>
    );
  }
}

export default connect(...)(Form);

_Dumb component rendering connected component:_

class LoginForm extends Component {
  constructor(props, context) {
    super(props, context);
  }

  render() {
    return (
      <Form id="loginForm">
        this is a test
      </Form>
    );
  }
}

Changing the text this is a test will not cause the component to re-render. Replace <Form> with <div> and everything works as expected. Replace connect()(Form) with just Form and everything works as expected.

Repository demonstrating issue is available at https://github.com/bunkat/counter. It is the react-redux counter example with babel6 hot loading and a new connected wrapper component.

To reproduce the issue:

  1. git clone https://github.com/bunkat/counter.git
  2. cd counter
  3. npm install
  4. npm start
  5. Open browser to http://localhost:3000
  6. Edit components/Counter.js
  7. Modify the render method, change Clicked to Not Clicked

The module will be updated via HMR, but the Counter component will not be rendered with the new text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions