Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
Syntax error: Unexpected token, expected "{" (8:16) - Problem with arrow function

i'm new to React and i'm creating a form following a internet tutorial, but just in the start i've run into this error: Syntax error: Unexpected token, expected "{" (8:16)

This is my code:

import React from 'react';
import './App.css';
import Form from './components/Form.js';

const handleSubmit = values => alert(JSON.stringify(values));
const initialValues = {}

function App() =>(
  <div>
    <Form handleSubmit={handleSubmit} initialValues={initialValues} />
  </div>
)

export default App;
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Your function should be an arrow function:

const App = () => (
  <div>
    <Form handleSubmit={handleSubmit} initialValues={initialValues} />
  </div>
);

or a normal function with a return:

function App() {
  return (
    <div>
      <Form handleSubmit={handleSubmit} initialValues={initialValues} />
    </div>
  );
}

More about functions here.

about 4 years ago · Juan Pablo Isaza Report

0

Additional you can pass the brackets comes after App if function has one parameter.

const App = parameterA => (
  <div>
    <Form handleSubmit={handleSubmit} initialValues={initialValues} />
  </div>
);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!