4
錯誤信息 -<Provider>不支持隨時改變`store`在reactnative +終極版
供應商不支持隨時改變商店。您最有可能看到此錯誤,因爲您已更新到Redux 2.x和React Redux 2.x,它們不再自動重新加載減速器。有關遷移說明,請參閱https://github.com/reactjs/react-redux/releases/tag/v2.0.0。
configureStore.js -
import { createStore,applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
export default function configureStore(initialState) {
const store = createStore(reducers,{},applyMiddleware(ReduxThunk));
if (module.hot) {
// console.log("in module.hot");
console.log(reducers);
module.hot.accept(() => {
const nextRootReducer = require('./reducers/index').default;
store.replaceReducer(nextRootReducer)
});
}
return store;
}
App.js -
render(){
const store = configureStore();
return(
<Provider store = {store}>
<Container>
<Login/>
</Container>
</Provider>
refrence - 視頻 - https://www.youtube.com/watch?v=t2WXfAqLXJw
github上 - 在給定的視頻https://github.com/reactjs/react-redux/releases/tag/v2.0.0
方案是這樣實現