You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Next.js project which has some pages that are rendered in different ways, but focusing plainly on the ISR pages - Take a look:
This ISR page gets its data completely statically, without the user of getServerSideProps or getStaticProps.
For reference, data is in the following format (I use a var called appl which plucks the correct array):
const { data } = useSWR(myKey, { myObj }) const appl = _head(data?.matched)
(I use lodash to take the head of the res and grab "matched" returned from my API)
I have the following for attempted to "optimistically" update the "notes" field on a client application form
When using the above, the page calls a full revalidation. Everything still works the same way, but data is set to undefined during the above function, which is not desired in this case. I can tell this because I have it logging and I also see my "skeleton" component render when I click to patch the data.
This is obviously pretty hard to "guess" what's wrong in my case, and I understand that, so if anyone would be willing to help it'd be greatly appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys,
I have a Next.js project which has some pages that are rendered in different ways, but focusing plainly on the ISR pages - Take a look:
This ISR page gets its data completely statically, without the user of
getServerSideProps
orgetStaticProps
.For reference, data is in the following format (I use a var called
appl
which plucks the correct array):const { data } = useSWR(myKey, { myObj })
const appl = _head(data?.matched)
(I use lodash to take the head of the res and grab "matched" returned from my API)
I have the following for attempted to "optimistically" update the "notes" field on a client application form
const handleUpdateNotes = async (e) => { e.preventDefault(e) mutate({ ...data, notes: notesValue, }, false) closeAllOpenUI() patchApplication(notesValue) mutate() fireNotesUpdatedToast() }
This code ensures the patch takes place, and I even get some "pretty" quick updating client side data for the notes, *but it doesn't happen instantly.
Instead, I saw 1.2.0 brought some optimistic updates which I'd love to implement here (as it's JUST too slow unfortunately).
So I have tried the following:
const handleUpdateNotes = async (e) => { e.preventDefault(e) try { await mutate(patchApplication(notesValue), { optimisticData: [{ ...appl, notes: notesValue }], rollbackOnError: true, populateCache: true, revalidate: false }).then(res => console.log(res)) closeAllOpenUI() fireNotesUpdatedToast() } catch (error) { console.log(error) } }
When using the above, the page calls a full revalidation. Everything still works the same way, but
data
is set to undefined during the above function, which is not desired in this case. I can tell this because I have it logging and I also see my "skeleton" component render when I click to patch the data.This is obviously pretty hard to "guess" what's wrong in my case, and I understand that, so if anyone would be willing to help it'd be greatly appreciated.
Cheers,
MJS
Beta Was this translation helpful? Give feedback.
All reactions