I'm trying to implement a shopping cart in my app. I created another file that has the functions I want to be called I keep getting an invalid hook call.
export function CartProvider(props) {
      const [items, setItems] = useState([]);
    
    function addItemToCart() {
        console.log("test")
    }
  return (
    <CartContext.Provider 
      value={{items, setItems, getItemsCount, addItemToCart, getTotalPrice}}>
      {props.children}
    </CartContext.Provider>
  );
}
There is more code in the file but I've narrowed the issue down to this, but as soon as I import the CartContext and make it a const I get the issue.
import {CartContext} from '../CartContext'
const {addItemToCart} = useContext(CartContext)
export default class ProductCard extends Component {
constructor(props) {
    super(props)
    this.state = {
        name: this.props.postname,
        price: this.props.postprice,
        image: this.props.postimage,
        description: this.props.postDescription,
        quantity: this.props.postquantity,
        
    }
    
}