【问题标题】:react native Redux-DevTools-Extension not working反应原生 Redux-DevTools-Extension 不起作用
【发布时间】:2021-03-12 11:01:33
【问题描述】:

我正在使用:

"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 状态。

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

【问题讨论】:

    标签: react-native redux react-redux redux-devtools-extension


    【解决方案1】:

    我无法让它工作。我试过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-03-04
      • 1970-01-01
      • 2018-05-20
      • 2018-01-02
      • 2016-09-27
      • 1970-01-01
      • 2018-09-16
      • 2019-02-06
      • 2019-09-13
      相关资源
      最近更新 更多