notrab / react-use-cart

React hook library for managing cart state

Home Page:http://npm.im/react-use-cart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: addItem is not a function

brixNessia opened this issue · comments

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.

Hello

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

Thanks 🙏

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

This is the function that handles the addItem to cart
image

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

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!!

@Sudharsan-learning Hey

You have no CartProvider 😄

@notrab Thank you for your response.

I already found it.