Created
January 7, 2018 18:28
-
-
Save iamdanthedev/0639c411006a2c506e26b51492c8ac54 to your computer and use it in GitHub Desktop.
withModal hoc (semantic-ui-react modal)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { Modal, ModalProps } from './semantic'; | |
export function withModal<T extends {} = any>( | |
modalOptions: ModalProps | ((props: T) => ModalProps), | |
) { | |
return BaseComponent => props => { | |
const modalProps = | |
typeof modalOptions === 'function' ? modalOptions(props) : modalOptions; | |
return ( | |
<Modal {...modalProps}> | |
<BaseComponent {...props} /> | |
</Modal> | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment