Issue
I am creating a cart context for a Nextjs ecommerce store. When trying to pass the setCart to the value prop of the CartContext.Provider, TypeScript throws an error, Ill attach a screenshot below to the error as well as a screenshot of the code. Thanks!
Solution
Change your ICart interface declaration to:
import React from 'react'
interface ICart {
cart: ICartItem[] | null;
setCart: React.Dispatch<React.SetStateAction<ICartItem[]>>;
}
Answered By - lpizzinidev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.