setProduct hook isnt a function?

214 views Asked by At

I keep getting an error saying that the setProduct value isn't a function in my react code. Here is a codesandbox example of what I've been working on.

https://codesandbox.io/s/determined-jang-0ro1v

1

There are 1 answers

0
Bugbeeb On BEST ANSWER

I can't recommend typescript enough. The return value of useState is an array type. You need to unpack it using array syntax: const [product, setProduct] = useState()