Build an Event RSVP - Build an Event RSVP

Tell us what’s happening:

Hello, the code works as intended but it doesn’t passes, I’ve tried checking the logs and even tried my peers’ code which supposedly should worke and it returns me the same errors… The states get updated correctly and the information too so I’m kinda lost. Can anybody shed a light on this?

Your code so far

<!-- file: index.html -->
<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Event RSVP</title>
    <link rel="stylesheet" href="styles.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.development.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.development.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.26.5/babel.min.js"></script>
    <script
      data-plugins="transform-modules-umd"
      type="text/babel"
      src="index.jsx"
    ></script>
    <link rel="stylesheet" href="styles.css" />
  </head>

  <body>
    <div id="root"></div>
    <script
      data-plugins="transform-modules-umd"
      type="text/babel"
      data-presets="react"
      data-type="module"
    >
      import { EventRSVPForm } from './index.jsx';
      ReactDOM.createRoot(document.getElementById('root')).render(
        <EventRSVPForm />
      );
    </script>
  </body>
</html>
/* file: styles.css */
label{
  display:block;
  margin-bottom:8px
}
input{
  display:block
}
.hidden{
  display:none;
}
/* file: index.jsx */
const { useState } = React;

export function EventRSVPForm() {
const [name, setName] = useState('')
const [email, setEmail] = useState('')
const [attendees, setAttendees] = useState('')
const [diet, setDiet] = useState('')
const [addGuests, setAddGuests] = useState(false)
const [submittedData, setSubmittedData] = useState(null)



const handleSubmit = (e) => {
  e.preventDefault()
  
  setSubmittedData({name, email, attendees, diet, addGuests})

  

  setName('')
  setEmail('')
  setAttendees('')
  setDiet('')
  setAddGuests(false)


  
  


}

  return (
    <div>
    <form onSubmit={handleSubmit}>
      <label>
        Name
        <input 
        required 
        type="text" 
        placeholder="Your name" 
        value={name} 
        onChange={e => setName(e.target.value)}/>
      </label>
      <label>
        Email
        <input 
        required 
        type="email" 
        placeholder="Your email" 
        value={email} 
        onChange={e => setEmail(e.target.value)}/>
      </label>
      <label>
        Number of attendees
        <input 
        required 
        type="number" 
        placeholder="Number of atendees" 
        value={attendees} 
        onChange={e => setAttendees(e.target.value)}/>
      </label>
      <label>
        Dietary preferences
        <input 
        type="text" 
        placeholder="Dietary preferences (Optional)" 
        value={diet} 
        onChange={(e) => setDiet(e.target.value)}/>
      </label>
      <label>
        Bringing additional guests?
        <input 
        type="checkbox" 
        value={addGuests}onClick={() => {setAddGuests(n => !n)}}/>
      </label>

      <button 
      type="submit" 
      disabled={!name || !email || !attendees}>Submit RSVP</button>
    </form>

    {submittedData && <div>
    <p>RSVP Submitted!</p>
    <p>Name: {submittedData.name}</p>
    <p>Email: {submittedData.email}</p>
    <p>Number of attendees: {submittedData.attendees}</p>
    <p>Dietary preferences: {submittedData.diet === '' ? 'None' : submittedData.diet}</p>
    <p>Bringing additional guests: {submittedData.addGuests ? 'Yes' : 'No'}</p>
    </div>}
    </div>
  )
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0

Challenge Information:

Build an Event RSVP - Build an Event RSVP
https://www.freecodecamp.org/learn/full-stack-developer/lab-event-rsvp/build-an-event-rsvp

Looking at the console, looks like there is something wrong related to the tests.

I think the problem isn’t in your code, it’s something else related to how tests work.

1 Like

I’ve looked the console and I haven’t found anything seemingly related to the errors, anything I can understand at least… I guess I’ll leave this posted and come back to this later. Thanks for your comment, I appreciate it.

Can you check the Console tab in DevTools, not the one under the Preview in freeCodeCamp?

Try pressing F12 to open DevTools, then go to the Console tab.


These are the errors I am getting on my browser console. I don’t know how to interpret them. One of them throws me an error for “await” but I haven’t used it on my code…

I can only confirm the second image, as those are the same errors I get after clicking the
Run the Tests button.

You can follow this GitHub issue for updates on the problem.

1 Like

Thanks for the help, I will be checking the github post!

1 Like