Reputation: 59
When I want to use useState, one of the hooks structures, in react, he gets angry with me const [apple, setApple] = useState(false)
. I have never encountered such a problem before. Could there be a place I overlooked?
Upvotes: 0
Views: 1000
Reputation: 345
you have to write your hook inside of a component, when you start the name of component with Lowercase letters, it defines as a normal function not a component, change it to Capital letters...
import React from "react"
export default function Apple(props) {
const [apple, setApple] = React.useState(false);
return (
<div>
YOUR_CONTENT
</div>
)
}
Upvotes: 1