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.
Asked
Active
Viewed 152 times
-2
-
1Please update your question to include a [minimal, complete, and reproducible code example](https://stackoverflow.com/help/minimal-reproducible-example) in your question. – Drew Reese Feb 10 '22 at 23:56
-
while this question could better pinpoint the line of code, I would consider a codesandbox a reproducible example – Bugbeeb Feb 11 '22 at 00:08
1 Answers
1
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()

Bugbeeb
- 2,021
- 1
- 9
- 26