根据用户ID

时间:2018-10-26 17:53:06

标签: firebase react-native redux redux-persist

我正在使用Redux,Redux-Persist,React-Redux-Firebase和Firebase本身开发React-Native应用程序。我已经掌握了它,以便可以使用Redux-Persist成功地将Firebase用户和库项目列表持久保存到本地存储中。

我要解决的问题是,当有人登录到应用程序并将一些内容保存到他们的库中时,注销并返回到与来宾用户相同的屏幕,这些项仍然存在。它们与电话绑定,而不与用户绑定。

我不确定它是否有帮助,但是这是我保持状态的代码:

/** Imports... */

firebase.initializeApp(config);

const rrfConfig = {
  userProfile: "users",
  enableRedirectHandling: false, // since react-native does not support http
  firebaseStateName: "firebase" // should match the reducer name ('firebase' is default)
};

const createStoreWithFireBase = compose(
  reactReduxFirebase(firebase, rrfConfig)
)(createStore);

const rootPersistConfig = {
  key: "root",
  storage,
  blacklist: ["search", "webSocket"],
  stateReconciler: autoMergeLevel2
};

const libraryPersistConfig = {
  key: "library",
  storage,
  whitelist: ["items"]
};

const rootReducer = combineReducers({
  library: persistReducer(libraryPersistConfig, libraryReducer),
  search: searchReducer,
  firebase: firebaseReducer,
  webSocket: webSocketReducer
});

export const store = createStoreWithFireBase(
  persistReducer(rootPersistConfig, rootReducer),
  applyMiddleware(thunk.withExtraArgument(getFirebase))
);

export const persistor = persistStore(store);

将数据绑定到特定用户,然后从本地存储中提取数据的最佳方法是什么?

0 个答案:

没有答案