ant-design: Switch: cannot get event object while fire click/change event
Version
3.0.0-alpha0
Environment
Chrome 59.0.3071.115
Reproduction link
https://ant.design/components/switch-cn/
Steps to reproduce
【Background】 Use Switch in a clickable component; prevent parent component’s click event while fire Switch’s click event.
【Codes】
<Switch onChange={(checked) => {
//TODO
return false
}} onClick={(e) => {
console.log(e) //e输出为Boolean值:true/false, value of checked
e.preventDefault(); // Error
e.stopPropagation();
}} />
【Problem】 Cannot get the event object when trigger click event in Switch Component
What is expected?
get click event object when fire click event
What is actually happening?
null
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
Commits related to this issue
- Pass event (#36) ref: ant-design/ant-design#7181 — committed to react-component/switch by zombieJ 5 years ago
- update rc-switch close #7181 — committed to ant-design/ant-design by zombieJ 5 years ago
- update rc-switch (#14560) close #7181 — committed to ant-design/ant-design by zombieJ 5 years ago
OK… I think it is an abused example of Transfer. But you can try this as workaround: