I'm having problems refreshing my component
The Redbox is where the problem is that's the only way I was able to refresh the component to fetch the data. I know you're wondering why am I using a custom hook for that because just I want to simplify the code in each component
The yellow box is the custom hook to fetch data
This is the only way I'm able to refresh the component to fetch data because when the component mounts the required information for the data to be fetched is not defined, but when I refresh it, it's defined
1 Reply
I recommend using an existing library like React Query, since fetching directly has a lot of footguns that can trip you up. For adding to the cart you'd then a use a mutation, and trigger the cart to revalidate if that was successful