Write down a "withModal" hight order component, which will accept two arguments [modalName: String] and [modalComponent: React.Component] and render modalComponent into portal. Also, this HOF should inject 'showModal' and 'hideModal' to a new collection of props that are passed to the base component. eq:
import { compose, withHandlers } from 'recompose';
const PricingModal = ({ title, onHide }) => <button onClick={onHide}>Hide {title} modal</button>
const enhance = compose(
withModal('pricing', PricingModal),
withHandlers({
showPricing: ({ openModal, hideModal }) => () =>
openModal('pricing', {
title: 'Pricing',
onHide: (data) => hideModal('pricing')
})
})
)