notrab / react-use-cart

React hook library for managing cart state
http://npm.im/react-use-cart
Apache License 2.0
367 stars 48 forks source link

TypeError: addItem is not a function #102

Closed brixNessia closed 2 years ago

brixNessia commented 2 years ago

AddItem is working at first, but when I refresh the page this AddItem is not a function error is displayed. I've tried console.log() the value of useCart and all the function is gone when I refresh it.

notrab commented 2 years ago

Hello

please provide some kind of codesandbox showing the error so I can help further.

Thanks 🙏

brixNessia commented 2 years ago

This is the value if the useCart() that holds the addItem function when I don't refresh the page. useCartWorking

This is the value if the useCart() that holds the addItem function when I refresh the page. useCartNotWorking

This is the error when I try to addItems in the cart Error

@notrab

brixNessia commented 2 years ago

This is the function that handles the addItem to cart image

notrab commented 2 years ago

please provide some kind of codesandbox showing the error so I can help further.

Sudharsan-learning commented 2 years ago

Here the code sandbox link

https://codesandbox.io/s/modest-sid-gkvyp1?file=/src/App.js

I have been provided the same code in npm package Demo code and it shows the same error. Please help us!!

notrab commented 2 years ago

@Sudharsan-learning Hey

You have no CartProvider 😄

Sudharsan-learning commented 2 years ago

@notrab Thank you for your response.

I already found it.