Redux-persist:无法在键“ _firestore”上处理值为“ [object Object]”的循环状态

时间:2019-01-17 06:02:33

标签: react-native google-cloud-firestore redux-persist

我在动作网站上尝试了许多不同的方法,但是当我发布android apk文件时问题仍然相同。抱歉,我是redux-persist的新手,在调试模式下一切正常。

这是我使用adb logcat

时的错误
redux-persist: cannot process cyclical state.
Consider changing your state structure to have no cycles.
Alternatively blacklist the corresponding reducer key.
Cycle encounted at key "_firestore" with value "[object Object]".

这是我的操作代码

  try {
    let pendingPostList =[]
    let postList=[]
    let user = {}
    const userId = await AsyncStorage.getItem('uid')
    userrRef = firestore.collection('user').doc(userId)
    await userrRef.get().then((val)=>{
        user = val.data()
    })
        await Promise.all(user.userFollowing.map(async(val)=>{
            postRef = 
 firestore.collection('post').where('postOwner','==',val)
            await postRef.get().then(async(querySnapshot)=>{
                await querySnapshot.forEach(async(doc)=>{
                    let list ={
                        ...doc.data(),
                        postId:doc.id      
                    }
                pendingPostList.push(list)
                })  
            })
        }))

        await Promise.all(pendingPostList.map(async(val)=>{
            userRef =firestore.collection('user').doc(val.postOwner)
            await userRef.get().then((user)=>{
                let owner ={
                    ...user.data()
                }
                let post={
                    ...val,
                    owner:owner
                }
                postList.push(post)
            })
        }))
        dispatch(_successGetPostListt(postList))
    }
    catch (e) {
        dispatch(_failedGetPostList(e))
    }

}

这是我的configurestore

import { AsyncStorage } from "react-native";
import { composeWithDevTools } from 'redux-devtools-extension'
import { createStore, applyMiddleware, compose } from "redux";
import thunk from "redux-thunk";
import { persistStore } from "redux-persist";
import reducer from "../Reducers";

const composeEnhancers = composeWithDevTools({ realtime: true })

export default function configureStore(onCompletion: () => void): any {
const enhancer = composeEnhancers(
    applyMiddleware(thunk)
);

const store = createStore(reducer, enhancer);
persistStore(store, { storage: AsyncStorage }, onCompletion);

return store;
}

0 个答案:

没有答案