Skip to content

Instantly share code, notes, and snippets.

@iamdanthedev
Created January 7, 2018 18:28
Show Gist options
  • Save iamdanthedev/0639c411006a2c506e26b51492c8ac54 to your computer and use it in GitHub Desktop.
Save iamdanthedev/0639c411006a2c506e26b51492c8ac54 to your computer and use it in GitHub Desktop.
withModal hoc (semantic-ui-react modal)
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