List In UI Not Showing New Data Until Refreshed tRPC React-Query

II am showing a shopping list of items. I can create new items from web form but they don't show in the page until I refresh or click off the page and then click back on the webpage. Am I using react-quest / tRPC queries properly? https://stackoverflow.com/questions/74411386/list-in-ui-not-showing-new-data-until-refreshed-trpc-react-query
Stack Overflow
List In UI Not Showing New Data Until Refreshed: tRPC React-Query
I am trying to use tRPC (which wraps react-query) to get data into a shopping list. I think the problem may be that I am querying for my shoppingList/shoppingListId and item's separately. Maybe thi...
5 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
currenthandle
currenthandle2y ago
@Micheaaa thanks! I ended up deconstructing refetch off the call that created my trpc query and then just called refetch() and that seemed to do the trick.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
theFern
theFern2y ago
Do you mind showing how you did this in your code? I'm having trouble invalidating or refetching queries upon successful mutation as well const utils = trpc.useContext() const students = trpc.student.getAll.useQuery() const addStudentTRPC = trpc.student.add.useMutation({ onSuccess() { utils.student.getAll.invalidate() }, }) This invalidation is currently not working for me
Want results from more Discord servers?
Add your server