我正在使用this
扩展看我的redux商店。当我打开远程调试器时,在控制台中我连接到remotedev-server,但我的redux工具说没有找到商店。
以下是我的商店设置
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import promiseMiddleware from 'redux-promise-middleware';
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'remote-redux-devtools';
import thunkMiddleware from 'redux-thunk';
import rootReducer from './src/Reducers/index';
import NavigationApp from './src/components/Navigation/Navigation';
const store = createStore(rootReducer, composeWithDevTools(
applyMiddleware(thunkMiddleware, promiseMiddleware()),
));
export default class App extends Component<{}> {
render() {
return (
<Provider store={store}>
<NavigationApp />
</Provider>
);
}
}
package.json
{
"name": "App",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.17.1",
"react": "16.0.0",
"react-native": "^0.54.2",
"react-native-elements": "^0.18.5",
"react-native-vector-icons": "^4.4.2",
"react-navigation": "^1.0.0-beta.22",
"react-redux": "^5.0.7",
"redux": "^3.7.2",
"redux-promise-middleware": "^5.0.0",
"redux-thunk": "^2.2.0",
"remote-redux-devtools": "^0.5.12"
},
"devDependencies": {
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"eslint-config-rallycoding": "^3.2.0",
"jest": "21.2.1",
"react-test-renderer": "16.0.0"
},
"jest": {
"preset": "react-native"
}
}
我也关注this
堆栈溢出线程的说明但没有雪茄。我最近的更新中遗漏了什么?我错过了一个与本机redux设置相关的软件包吗?
旁注,我的行动是回复已解决的承诺
答案 0 :(得分:0)
在你对createReducer的调用中:
const store = createStore(rootReducer, composeWithDevTools(
applyMiddleware(thunkMiddleware, promiseMiddleware()),
));
您没有指定商店的初始数据(在documentation中称为preloadedState)。
您需要将代码更改为:
const store = createStore(rootReducer, preloadedState, composeWithDevTools(
applyMiddleware(thunkMiddleware, promiseMiddleware())));