DEV Community

Discussion on: #Todo app tutorial in Ember Octane for those who know React

Collapse
 
devhammed profile image
Hammed Oyedele

Nice article 👍
But I see some things that you can improve.

  • There is a typo in the React example of delete, it should be this instead:
this.setState({ model: [...model] })
  • The delete method can be shorten to use only filter:
removeItem(id) {
    let updatedModel = this.state.model
        .filter(item => item.id !== id)

    this.setState({ model: updatedModel })
}

This is more concise, I don't know how this translates to Ember but I am guessing it will be a re-assginment like:

@action
delete(model, id) {
   model = model.filter(item => item.id !== id)
}