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 this component that I created where I'm testing useOptimistic and don't have a real backend to call to. So my data source is a variable in another module called messagesOnApi. I have a local state variable messagesRetrievedFromApi that I use to load the data from my fake api, messagesOnApi, and then when I call useOptimistic I pass the messagesRetrievedFromApi state variable as the first parameter.
When I make my update to the api data I add a delay but instead of my optimistic data updating immediately it only updates after the delay. Why?
This is the github with entire source, https://github.com/PacktPublishing/Full-Stack-React-TypeScript-and-Node-2nd-Edition/blob/main/Chap5/components/src/OptimisticMessages.tsx. This is the main component.
Can you distill this into a minimal repro with as little files as possible? You can use https://react.new for that.
Here's a new project with just the affected component OptimisticMessages, https://github.com/jsoneaday/optimistic. Note I am using useTransition and not forms in this example.
I have this component that I created where I'm testing useOptimistic and don't have a real backend to call to. So my data source is a variable in another module called messagesOnApi. I have a local state variable messagesRetrievedFromApi that I use to load the data from my fake api, messagesOnApi, and then when I call useOptimistic I pass the messagesRetrievedFromApi state variable as the first parameter.
When I make my update to the api data I add a delay but instead of my optimistic data updating immediately it only updates after the delay. Why?
This is the github with entire source, https://github.com/PacktPublishing/Full-Stack-React-TypeScript-and-Node-2nd-Edition/blob/main/Chap5/components/src/OptimisticMessages.tsx. This is the main component.
The text was updated successfully, but these errors were encountered: