Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this fixing the issue? This is just removing the new post from being added to the local cache, but isn't going to fix the network error, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a network error; we're successfully creating a post. However, we're trying to add static frontend data (title and description) to the local cache. The issue is that the local cache requires additional fields in the new post (but we have only title and description), which causes an error and leads to the catch block being triggered. To fix this, I removed the new post and updated code to [...(currData?.listPosts?.posts || [])] . The error occurs because the local cache needs more fields for the new post. Specifically, the new post should have these fields:{
"urn",
"type",
"postType": "Post type",
"content": {
"contentType": "TEXT",
"title",
"description",
"link": null,
"media": null
}
}
And currently, we're only adding the title and description to the local cache using the onCreate method as follows:
onCreate={(urn, title, description) => {
addToListPostCache(
client,
{
urn,
properties: {
title,
description: description || null
}
},
pageSize
);
setTimeout(() => refetch(), 2000);
}}
I also added screencast how this error is occuring with the newpost
Screencast from 02-01-24 12:08:39 PM IST.webm