Uncaught Error: redux-persist: cannot process cyclical state. Consider changing your state structure to have no cycles.

548 views
Skip to first unread message

Theo

unread,
Apr 1, 2017, 11:28:59 AM4/1/17
to Firebase Google Group
OS: Windows Pro 10
Firebase: 3.6.9
Firebase-bolt: 0.8.1
Firebase-tools: 3.3.0


So, I'm using redux-offline (which uses redux-persist) in my project, and am having an issue with action payload/firebase results being non-serialized (See attached image).

How do I serialize firebase results?

My action code is as follows:


// fetch posts
export function fetchPosts() {
  console
.log("Load Posts has been fired");
 
return dispatch => {
   
Posts.on('value', posts => {
      dispatch
({
        type
: 'FETCH_POSTS',
        payload
: posts.val(),
        meta
: {
          offline
: {
            effect
: {},
            commit
: { type: 'FETCH_POSTS_COMMIT', meta: { posts } },
            rollback
: { type: 'FETCH_POSTS_ROLLBACK', meta: { posts } },
         
}
       
}
     
});
   
});
 
};
}


// fetch comments
export function fetchComments() {
  console
.log("Load Comments has been fired");
 
return dispatch => {
   
Comments.on('value', comments => {
      dispatch
({
        type
: 'FETCH_COMMENTS',
        payload
: comments.val(),
        meta
: {
          offline
: {
            effect
: {},
            commit
: { type: 'FETCH_COMMENTS_COMMIT', meta: { comments } },
            rollback
: { type: 'FETCH_COMMENT_ROLLBACK', meta: { comments } },
         
}
       
}
     
});
   
});
 
};
}



error.jpg

Jacob Wenger

unread,
Apr 4, 2017, 9:45:16 PM4/4/17
to fireba...@googlegroups.com
What do the contents of posts.val() and comments.val() look like? I'm pretty sure they should just be regular JavaScript objects so I'm surprised to see an error saying they have circular references. You might need to run them through JSON.stringify() when writing them and then JSON.parse() them when reading them. But if you send us the contents, it may become obvious what is going wrong.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/d5d7ca4c-0d79-4048-892c-fcdf01df5812%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages