Skip to content

HMR: connected component gets disconnected from store #670

Closed

Description

Description

Connected component gets disconnected from store when code changed and applied by HMR.

Steps:

Expected behavior

Remove <p>test</p> and 'Increment' component should receive changed state when clicked on one of the buttons.

Actual behavior

When I remove <p>test</p> HMR does its code updating which leads to the problem that 'Increment' component doesn't get new store state. You can click on the buttons and the counter stays the same. I can see the actions dispatched in Redux devtools.

I found out that this is the case when the component above in the hierarchy is a container component which subscribed to state which is not subscribed in other components in the tree. You don't get the problem when you change
https://github.com/hoschi/bare-minimum-react-hot-rr4-redux/blob/08740ca8bac9a2d2d7e7527346f0ae36dde3234e/src/components/AppBarDesktopContainer.jsx
to:

import { connect } from 'react-redux';
import AppBarDesktop from './AppBarDesktop';

export default connect((state) => ({
    newsData:state.counter
}))(AppBarDesktop);

and do the same steps described in the Description part.

Environment

react-redux 5.0.4, I tried also 5.0.2 and 5.0.3 without effect
https://github.com/hoschi/bare-minimum-react-hot-rr4-redux/blob/08740ca8bac9a2d2d7e7527346f0ae36dde3234e/package.json

Run these commands in the project folder and fill in their results:

  1. node -v: 6.3.1
  2. npm -v: 3.10.3

Then, specify:

  1. Operating system: Linux (Arch)
  2. Browser and version: Chrome, 56.0.2924.87 (64-bit)

Reproducible Demo

https://github.com/hoschi/bare-minimum-react-hot-rr4-redux/tree/disconnected-component

Probably related issues

fun fact: You have to delete the tag below, deleting one above will trigger this bug and 'fixes' the one I'm reporting here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions