enter image description hereI am trying to save my data to local Storage and it succeeds, but when reloading the page it disappears, is there any way to handle it, I am new and need help, thanks a lot
Base on your code, you lose your storage since the effect will override values and set it empty, and this happens since you do not validate if cart items are empty or not.
In react hook in your example, the first call will be with init value (maybe it's null), and if it's not fetching data again so that it will be removed.
Try to add this to your effect (as an example):
if(cartsItem.length > 0){
// set local storage.
}
Another thing, you need to make sure if this is not fully coded if there's any place was remove local storage and its important.