MCPcopy
hub / github.com/kenberkeley/react-demo / handleSubmit

Method handleSubmit

src/components/Msg/MsgForm/index.js:82–94  ·  view source on GitHub ↗
(evt)

Source from the content-addressed store, hash-verified

80
81 /* 同样地,提交表单前需要根据当前 mode 进行对应的操作 */
82 handleSubmit (evt) {
83 evt.preventDefault()
84 let { pathname } = this.props.location
85 let opt = isAddMode(pathname) ? 'addMsg' : 'modMsg'
86
87 // 提交后,由于会触发 componentWillReceiveProps
88 // 因此这里需要把该函数“清空”,避免浪费性能
89 this.updateState = () => {}
90
91 this.props[opt](this.state).then(({ id }) => {
92 this.context.router.replace(`/msg/detail/${id}`)
93 })
94 }
95
96 render () {
97 // 使用 call/apply,让 tpl 中的上下文与当前一致

Callers 1

msg-form.jsxFile · 0.45

Calls 1

isAddModeFunction · 0.85

Tested by

no test coverage detected