【问题标题】:Conversion React-Redux from v1.x to v2.x将 React-Redux 从 v1.x 转换为 v2.x
【发布时间】:2018-12-13 12:43:41
【问题描述】:

所以我还是新手,我发现的所有教程都使用了 React-Redux v1 的示例,但现在我的代码甚至无法编译,给我这个错误: 不支持即时更改store。您很可能会看到此错误,因为您更新到 Redux 2.x 和 React Redux 2.x,它们不再自动热重载减速器。有关迁移说明,请参阅https://github.com/reduxjs/react-redux/releases/tag/v2.0.0我尝试按照链接上的示例进行操作,但失败了。这是我在进行任何更改之前的代码:

import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import firebase from 'firebase';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
import AppContainer from './AppNavigator';

console.disableYellowBox = true;

class App extends Component {
    async componentDidMount() {
        const config = {
            apiKey: "",
            authDomain: "",
            databaseURL: "",
            projectId: "",
            storageBucket: "",
            messagingSenderId: ""
          };
        await firebase.initializeApp(config);
    }

    render() {
        const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));

        return (
            <Provider store={store}>
                <AppContainer />
            </Provider>
        );
    }
}

export default App;

【问题讨论】:

标签: reactjs react-native redux react-redux


【解决方案1】:

我解决了我的问题。我不得不将createStore 线移到课堂外

【讨论】:

  • 这并没有提供问题的答案。要批评或要求作者澄清,请在他们的帖子下方留下评论。 - From Review
  • 实际上,@richbai90,这显然 的答案。这是OP发布他为解决自己的问题所做的事情。也出现在我的评论队列中。我稍微编辑了答案以使其更清楚。
猜你喜欢
  • 2017-12-22
  • 1970-01-01
  • 2016-12-03
  • 2018-10-15
  • 1970-01-01
  • 1970-01-01
  • 2021-11-13
  • 1970-01-01
  • 2017-12-22
相关资源
最近更新 更多