0
這是我到目前爲止有:如何使用React/Redux發送內容?
export default connect(
(state) => ({
search: state.search
}),
(dispatch) => ({
onSearch: (location) => (q) => dispatch(actions.push(getUrlWithQS(location, { qs: { q } }))),
onClipCardClick: (location) => (clip) => dispatch(actions.push(getUrlWithQS(location, { pathname: `/clips/${clip.id}` })))
}),
(stateProps, dispatchProps, ownProps) => ({
...stateProps,
...dispatchProps,
...ownProps,
onSearch: dispatchProps.onSearch(ownProps.location),
onClipCardClick: dispatchProps.onClipCardClick(ownProps.location)
})
)(Home)
我沒有寫這個(我繼承),所以在onSearch
顯然調度的東西,通過新的查詢?那麼會發生什麼情況是URL更改爲http://localhost:5000/?q=whatever
如何在不更改URL的情況下發送郵件?
編輯
import { push, goBack } from 'react-router-redux'
actions.push = push
而觸發onSearch
組件的樣子:
onChange (e) {
if(this.state.isMobile) {
return this.props.onSubmit(e.target.value)
}
if(this.props.autoSearch) {
this.props.onSubmit(e.target.value)
}
this.props.onAutocomplete(e.target.value)
this.setState({
value: e.target.value,
selectedSearch: false
})
}
它不是在表單提交。它處於輸入框的更改事件中。 – Shamoon
輸入框不在最終提交的表單中嗎? – lorefnon
你能提供'actions.push'的定義嗎? – lorefnon