Skip to content

'characters' is not defined #22

Description

@RickHankel

I get this error when adding the removeCharacter method to the App component and I can't figure out what's wrong, please help.

./src/App.js
  Line 39:31:  'characters' is not defined  no-undef

Search for the keywords to learn more about each error.
class App extends Component {
  state = {
    characters: [
      {
          name: 'Charlie',
          job: 'Janitor'
      },
      {
          name: 'Mac',
          job: 'Bouncer'
      },
      {
          name: 'Dee',
          job: 'Aspiring actress'
      },
      {
          name: 'Dennis',
          job: 'Bartender'
      }
  ]
  }

  removeCharacter = (index) => {
    const {characters} = this.state
  
    this.setState({
      characters: characters.filter((character, i) => {
        return i !== index
      }),
    })
  }

  render () {
    return (
      <div className='container'>
        <Table characterData={characters} removeCharacter={this.removeCharacter} />
      </div>
    )
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions