vigetlabs/microcosm

microcosm-addons: ActionForm - Pass form as second argument to action state callbacks

nhunzaker opened this issue · 0 comments

Right now it's hard to reset a form when an action completes. You have to assign a ref to the form, which is kind of a bummer.

What if instead we passed the form in the callbacks?

class MyForm extends React.Component {
  onDone(_payload, form) { 
    form.reset()
  }

  render() {
    return (
      <ActionForm action="doSomething" onDone={this.onDone}>
        ...
      </ActionForm>
    )
  }
}