Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React by Example Building the Application Removing Names From the List

props.removeGuestAt is not a function - compile time error

Remove button is not working, it is showing me an error that "props.removeGuestAt is not a function" at GuestList.js file. Please help me get through this.

2 Answers

Jesus Mendoza
Jesus Mendoza
23,289 Points

Hey Tilak. Can you show us your code?

import React from 'react';
import PropTypes from 'prop-types';
import Guest from './Guest'

const GuestList = props =>
  <ul>
    {props.guests
        .filter(guest => !props.isFiltered || guest.isConfirmed)
        .map((guest, index) =>
      <Guest
        key = {index}
        name = {guest.name}
        isConfirmed = {guest.isConfirmed}
        isEditing = {guest.isEditing}
        handleConfirmation = {() => props.toggleConfirmationAt(index)}
        handleToggleEditing = {() => props.toggleEditiongAt(index)}
        setName = {text => props.setNameAt(text, index)}
        handleRemove = {() => props.removeGuestAt(index)} />
    )}
  </ul>;

GuestList.propTypes = {
  guests: PropTypes.array.isRequired,
  toggleConfirmationAt: PropTypes.func.isRequired,
  toggleEditiongAt: PropTypes.func.isRequired,
  setNameAt: PropTypes.func.isRequired,
  isFiltered: PropTypes.bool.isRequired,
  removeGuestAt: PropTypes.func.isRequired

};

export default GuestList;

In app.js <GuestList> removeGuestAt: {this.removeGuestAt}</GuestList>

I made a mistake before and wrote this.state.removeGuestAt instead of this.removeGuestAt. Now remove functionality is working.