3

所以我能够成功地将我的商店链接到我的主 App.js,但现在我收到了关于存储数据的错误。我试图清除以查看它是否会做任何事情,并且我收到了类似的错误,它说它无法清除存储的数据存储 {}。

更新:问题与const storageredux-persist-sensitive-storage 库有关。不过,不知道如何用这个库保存数据。

商店.js:

const initialState = {};

const storage = createSensitiveStorage({
  keychainService: "myKeychain",
  sharedPreferencesName: "mySharedPrefs"
});

const config = {
  key: "root",
  storage,
};

const middleware = [thunk];

const reducer = persistCombineReducers(config, rootReducer);

export default () => {
  let store = createStore(
    reducer,
    initialState,
    compose(applyMiddleware(...middleware))
  );
  let persistor = persistStore(store);

  return { store, persistor }
}

index.js- 减速器

export default ({
    profile: profileReducer,
    auth: authReducer,
    photoSlider,
    trip: tripReducer,
    moment: momentReducer
})

我的一个减速器的例子:

import {
  SET_TRIP,
  CREATE_TRIP
} from '../actions';

const initialState = {
  trip: []
}

const tripReducer = (state = initialState, action) => {
  switch(action.type) {
    case SET_TRIP:
      return {
        ...state,
        trip: action.trip
      };
    case CREATE_TRIP:
      return {
        ...state,
        trip: action.payload
      }

    default:
      return state;
  }
}

export default tripReducer
4

1 回答 1

0

运行后我遇到了同样的问题react-native link react-native-sensitive-info

pod install通过从我的ios目录运行并重建项目来解决它

于 2019-01-16T00:31:53.010 回答