React, 回调函数怎么弄,

#1
  // 提交表单按钮
  handleSubmit () {

    this.setState({
      address: this.state.address,
    })
    setTimeout(() => {
      this.props.history.push('/order/QueryOrder/') //我想得到服务器生成order的id,用做这个路进跳转进订单的详情页。
    },1000)
    var date = new Date()
    let order = {
      customerId:this.state.customerId,
      address: this.state.customrName,
      deliveryTime: date,
      items: this.state.items,
    }

    AddOrderMutation.commit(environment, order); //向服务器发送创建新的order
    return order
  }

完全不明白这个回调函数怎么写,数据是 graphql 。

#2
AddOrderMutation.commit(environment, order, (id)=>{
     this.props.history.push('/order/QueryOrder/'+id)
})

然后在你定义 AddOrderMutation.commit 方法里面,等到服务器里面返回id的时候执行这个函数。

#3

试下在你表单提交成功后,在 componentWillReceiveProps() 做跳转