n my React application, I have to fetch the backend to:
list the products
display the price
list the availabilities
and more.
But all the time, if an error occurs, a 4xx or a 5xx, I repeat the same logic, everywhere: display a pop-in with an error message like "Your product is no more available", "There is no availabilities in the selected dates" or simply "An internal error occurred, try again later."
But it's always the same logic. I don't want to repeat the popin and the catch of the request everywhere. That's why I use the useContext hook
1 comment
[ 2.8 ms ] story [ 16.0 ms ] threadlist the products
display the price
list the availabilities
and more.
But all the time, if an error occurs, a 4xx or a 5xx, I repeat the same logic, everywhere: display a pop-in with an error message like "Your product is no more available", "There is no availabilities in the selected dates" or simply "An internal error occurred, try again later."
But it's always the same logic. I don't want to repeat the popin and the catch of the request everywhere. That's why I use the useContext hook