ReactNative 启用热过载错误报告

问题描述 投票:0回答:0

您看到此错误很可能是因为您更新到 Redux 2.x 和 React 2.x,它们不再自动热重载减速器


/**
 * Created by yusen on 2017/4/11.
 */

'use strict'

import {createStore, applyMiddleware, compose} from 'redux'
import thunk from 'redux-thunk'
import reducer from './reducer'
import {persistStore, autoRehydrate} from 'redux-persist'

const createStoreWithMiddleware = applyMiddleware(thunk)(createStore)

export default function configureStore(initialState) {
    const enhancer = compose(applyMiddleware(thunk))
    const store = createStore(reducer, initialState, enhancer)
    if(module.hot) {
        console.log('hot reload detected',reducer);
        if (module.hot.accept) {
            console.log('accept2', module.hot.accept);
        }
        module.hot.accept(() => {
            const nextRootReducer = require('./reducer').default
            store.replaceReducer(nextRootReducer)
            console.log("accept2223", nextRootReducer)
        })
    }
    // persistStore(store)
    // return compose(createStoreWithMiddleware(reducer, initialState))
    return store
}

我试过修改store issue,但是每次保存修改后的文件,还是报上面的错误。忽略那个错误后,我还是不能实时渲染修改后的内容到页面,页面还是原来的内容。 希望解决报错问题

react-native reload
© www.soinside.com 2019 - 2024. All rights reserved.