Overview: I just started learning react and I want to create a where, after the "Submit" button is pressed I get an alert with the monthly income * 2 (Calc() function). However when I writhe the Calc() function I geht a parsing error and the msg that I am missing a semicolon. I am not sure why that is appearing since the missinge semicolon is in the same line where my ' Calc() { ' code is and I never heard that at the start of a fucntiona semicolon is required.
Error msg: Error msg
Code below:
export function Parttime(){
const [monthly_income, setMonthly_income] = useState('');
//Error in same line where Calc() //
Calc(){
a = {monthly_income} * 2
alert("Your monthly income times 2 is:", {a})
}
//code continues after return( //
return (
Screenshot of Error msg:
Declare the function as arrow function
const Calc = () => {
// Your code
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.