I would like to call a useState function inside a component. I created a function named 'increase' and called useState function inside it to change the state value to 10. But when i call the function it throws error. Can anyone give me an explanation about why this happens. The code is as follows. Thanks in Advance!
import React, {useState} from 'react'
function ComponentOne() {
const[value,setValue]=useState(0);
let increase=()=>{
setValue(10)
}
increase();
return (
<div>
<h3>{value}</h3>
</div>
)
}
export default ComponentOne