Search code examples
reactjsreact-hooksdownshift

setProduct hook isnt a function?


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


Solution

  • 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()