Add withModalProps HOC
This commit is contained in:
parent
04ec3f0b6b
commit
3e470fee8a
|
@ -0,0 +1 @@
|
|||
export { default } from './with-modal-props'
|
|
@ -0,0 +1,21 @@
|
|||
import { connect } from 'react-redux'
|
||||
import { hideModal } from '../../actions'
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const { appState } = state
|
||||
const { props: modalProps } = appState.modal.modalState
|
||||
|
||||
return {
|
||||
...modalProps,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
hideModal: () => dispatch(hideModal()),
|
||||
}
|
||||
}
|
||||
|
||||
export default function withModalProps (Component) {
|
||||
return connect(mapStateToProps, mapDispatchToProps)(Component)
|
||||
}
|
Loading…
Reference in New Issue