Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Model.confirm throw error: Uncaught TypeError: Cannot read property 'apply' of undefined #5269

Closed
TangMonk opened this issue Mar 12, 2017 · 2 comments · Fixed by #5294
Closed
Assignees

Comments

@TangMonk
Copy link

TangMonk commented Mar 12, 2017

Environment(required)

  • antd version: 2.8.1
  • OS and its version: OS X
  • Browser and its version: chrome

What did you do? Please provide steps to re-produce your problem.

when click ok button in confirm modal:
it throw: Uncaught TypeError: Cannot read property 'apply' of undefined, like following image:

image

My code is:

      confirm({
        title: 'are you sure?',
        onOk () {
          // onDeleteItem(record.id)
        }
      })

What do you expected?

without error throw

Re-producible online demo

http://codepen.io/anon/pen/mWmQJx?editors=001

image

actually in official documentation is wrong too:

image

@TangMonk TangMonk changed the title Model.confirm throw error: Uncaught TypeError: Cannot read property 'apply' of undefined BUG: Model.confirm throw error: Uncaught TypeError: Cannot read property 'apply' of undefined Mar 12, 2017
afc163 referenced this issue Mar 19, 2017
@junbinku
Copy link

After hours of trying I have found out the issue.

Instead of:

onOk() { },
onCancel() { },

Use:

onOk: () => {},
onCancel: () = {},

This is because these function has to be binded.

@BranceLee
Copy link

楼上正解啊,终于找到出路了!
verifiedFile =()=>{
const { location: { query } ,customer} = this.props
const { companyId } = query || {}
console.log(this.props);
Modal.confirm({
title:"开户提示",
content:"用户资料不齐全是否开户",
onOk:()=>{
this.props.dispatch({
type:"customer/AuditPass",
payload:{
companyId:companyId,
processStatus:customer.processStatus
}
})
}
})
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants