-2

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

Chad Watkins
  • 531
  • 1
  • 8
  • 23
  • 1
    Please 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 Answers1

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