reactjs - React Native:_reactotronReactNative2.default.createStore 不是函数
问题描述
在我的 React Native 应用程序中,我无法让 Reactotron 工作,这意味着它无法连接到我的应用程序。该应用程序确实有 "reactotron-react-native": "1.14.0",
"reactotron-redux": "1.13.0",
我分别升级到"reactotron-react-native": "^3.5.0",
and"reactotron-redux": "^3.1.0"
我的应用程序坏了,但现在它正在连接到 Reactotron UI:
Reactotron 本身告诉我问题出在App.js
文件的第 53 行,这是下面的最后一行代码:
//eslint-disable-next-line
console.ignoredYellowBox = ["Setting a timer"];
import './ReactotronConfig';
import React, {PureComponent} from 'react';
import {
StyleSheet,
View,
StatusBar,
Linking,
Platform,
Alert,
} from 'react-native';
import {applyMiddleware, compose, combineReducers} from 'redux';
import {Provider} from 'react-redux';
import thunkMiddleware from 'redux-thunk';
import Reactotron from 'reactotron-react-native';
import logger from 'logger';
import OneSignal from 'react-native-onesignal';
import SplashScreen from 'react-native-splash-screen';
import {Sentry} from 'react-native-sentry';
import {
setJSExceptionHandler,
setNativeExceptionHandler,
} from 'react-native-exception-handler';
import {jsHandler, nativeHandler} from 'utils/error-handlers';
import RootNavigation from 'navigation/RootNavigation';
import LocalStorage from 'services/LocalStorage';
import reducers from 'reducers';
import {
setCurrentUser,
validateUserInformationForVoterVoice,
} from 'auth/loginActions';
import {handleEventsDeepLink} from 'events/actions';
import {handleBallotsDeepLink} from 'surveys-ballots/actions';
import {setResetPasswordKey} from 'auth/registrationActions';
import {setNotificationData, deepLinkReceived} from 'navigation/actions';
import {view} from 'utils/view';
import {v2Colors} from 'theme';
import env from 'env';
import base from 'base-endpoint';
import * as appcenter from 'utils/appcenterLogger';
import * as cache from 'utils/cache';
import * as regex from 'utils/helpers/regex';
const appReducer = combineReducers({
...reducers,
});
const middleware = applyMiddleware(thunkMiddleware);
//react-native-debugger config
// eslint-disable-next-line no-underscore-dangle
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = Reactotron.createStore(appReducer, composeEnhancers(middleware));
我刚刚熟悉了 Reactotron 的存在,它看起来是一种有效的调试工具,我想知道是否有人正在使用"reactotron-react-native": "^3.5.0",
并且"reactotron-redux": "^3.1.0"
可能知道第 53 行发生了什么?
我假设它需要像大多数 React Native 重大更改一样进行重构,但我还没有找到任何有关如何配置的文档store
,如果该行不再需要的话。
解决方案
根据文档: https ://github.com/infinitered/reactotron/blob/master/docs/plugin-redux.md
我必须确保我已经createStore
像这样导入了:
import {createStore, applyMiddleware, compose, combineReducers} from 'redux';
然后像这样重构商店:
const appReducer = combineReducers({
...reducers,
});
const middleware = applyMiddleware(thunkMiddleware);
//react-native-debugger config
// eslint-disable-next-line no-underscore-dangle
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
// const store = Reactotron.createStore(appReducer, composeEnhancers(middleware));
const store = createStore(appReducer, composeEnhancers(middleware, Reactotron.createEnhancer()));
推荐阅读
- flutter - 在 Widget 中初始化 StateProvider
- docker - Dockerfile 中的错误 + 解决“deb.debian.org”的临时失败
- gekko - 由于内存不足,找不到 GEKKO (IPOPT) 解决方案?
- selenium - Fitnesse 浏览器测试,在 Linux 中指向 Chrome 二进制文件的配置
- android - 在 ubuntu 上使用 cli avdmanager 创建新的 avd 时出现 chattr 错误
- php - 404错误的PHP配置设置
- azure - 如何将文件从 github 复制到 Azure Devops CI 管道中在 VSTS 代理上运行的容器
- kubernetes - 当我已经将 Pod 部署到我的节点时,是否需要重新创建它们以更新或实施新服务?
- python - 将复杂的嵌套 JSON 存储到 postgreSQL 的有效方法?
- c++ - 如何选择要随机化的数组中的特定数字?C++