Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Latest commit

 

History

History
32 lines (28 loc) · 753 Bytes

API.md

File metadata and controls

32 lines (28 loc) · 753 Bytes

Deleting a model

@load({
  user: User.getItem({id: 1})
})
class Profile extends Component {
  static propTypes = {
    user: User.instanceOf
  }

  deleteUser() {
	// TODO: below
    // If you have a loaded model instance you can call `delete` on the model
    // and pass in extra props to satisfy driver needs
    this.props.user.delete({ account: 'foo' }, () => {})

    // Alternatively, the `@load()` decorator injects a `deleteModel` function
    // into the component which can take a model class and an object of
    // parameters to delete
    this.props.deleteModel(User, { id: 1 }, () => {})
  }

  render() {
    return (
      <div>
        <a href='#delete' onClick={ ::this.deleteUser }>Delete</a>
      </div>
    )
  }
}