1

我在用着 :

"react-native": "0.63.3",
"react": "16.13.1",
"react-redux": "^7.2.2",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0"

这就是我的 redux 商店的样子:

const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['auth', 'user', 'whiteCommonData'], //only navigation will be persisted
};
const initialState = {};

const middleWare = [thunk];
// if (process.env.NODE_ENV !== 'production') {
//   middleware.push(createLogger());
// }
middleWare.push(createLogger());

const persistedReducer = persistReducer(persistConfig, rootReducer);

// const composeEnhancers = composeWithDevTools({
//   // Specify name here, actionsBlacklist, actionsCreators and other options if needed
// });

const composeEnhancers =
  (typeof window !== 'undefined' &&
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
  compose;

export const store = createStore(
  persistedReducer,
  // undefined,
  composeEnhancers(applyMiddleware(...middleWare)),
);

export const persistor = persistStore(store);

我阅读了文档并按照它所说的做了一切,但我无法让它工作,并且 chrome 扩展没有显示 redux 状态。 chrome redux-devtool-extension

我从redux-devtools-extension ducimentation尝试了 soultion 1.1 和 1.3,但没有任何改变。我也读过这个这个这个,但没有一个是有帮助的。我怎样才能让它工作?

4

1 回答 1

0

我无法让它工作。我尝试了 react-native-debugger并且效果很好。

这是我的 store.js :

const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['auth', 'user', 'whiteCommonData'], //only navigation will be persisted
};
const initialState = {};

const middleWare = [thunk];
// if (process.env.NODE_ENV !== 'production') {
//   middleware.push(createLogger());
// }
middleWare.push(createLogger());

const persistedReducer = persistReducer(persistConfig, rootReducer);

// const composeEnhancers = composeWithDevTools({
//   // Specify name here, actionsBlacklist, actionsCreators and other options if needed
// });

const composeEnhancers =
  (typeof window !== 'undefined' &&
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
  compose;

// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

export const store = createStore(
  persistedReducer,
  // undefined,
  composeEnhancers(applyMiddleware(...middleWare)),
);

export const persistor = persistStore(store);
于 2020-11-30T21:37:19.000 回答