Skip to content

Redux store unconnect #539

@leeratyou

Description

@leeratyou

It seems that RHL3 breaking connect with redux store. See .gif in the end of issue

react: 15.4.2
react-redux: 5.0.3
react-router: 4.0.0
react-hot-loader: 3.0.0-beta.6

index.js

import { AppContainer as HotContainer } from 'react-hot-loader'
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

import { configureStore } from './store'
const store = configureStore()

const root = document.getElementById('root')

const render = (Component, store) =>
  ReactDOM.render(
    <HotContainer>
      <Component store={store} />
    </HotContainer>,
    root
  )

render(App, store)

if (module.hot) {
    module.hot.accept('./App', () => {
        const NextApp = require('./App').default
        render(NextApp, store)
    })
}

store/index.js

import { createStore, applyMiddleware, compose } from 'redux'

import reducer from '../reducers'
import apiMiddleware from '../middlewares/apiMiddleware'

const enhancer = compose(
    applyMiddleware(apiMiddleware),
    window.devToolsExtension ? window.devToolsExtension() : f => f
)

export function configureStore(init) {

    const store = createStore(reducer, {}, enhancer)

    if(module.hot) {
        module.hot.accept('../reducers/', () => {
            const nextReducer = require('../reducers/index').default
            store.replaceReducer(nextReducer)
        })
    }

    return store
}

Or maybe i'm doing smth wrong?
6che9tmdnh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions