Add withModalProps HOC

This commit is contained in:
Alexander Tseung 2018-09-17 10:12:31 -07:00
parent 04ec3f0b6b
commit 3e470fee8a
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1 @@
export { default } from './with-modal-props'

View File

@ -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)
}