Skip to content

Instantly share code, notes, and snippets.

@ChemaCLi
Created March 19, 2022 00:58
Show Gist options
  • Select an option

  • Save ChemaCLi/d3428d4a3a5656008c3e9dd624b42910 to your computer and use it in GitHub Desktop.

Select an option

Save ChemaCLi/d3428d4a3a5656008c3e9dd624b42910 to your computer and use it in GitHub Desktop.
import { forwardRef } from "react"
import { Button as AButton } from "antd"
import { ModalContext, ModalContextProvider } from "../../../contexts"
function ModalButtonComponent({
button: Button = AButton,
modalProps,
modal,
title,
...props
}, ref) {
return (
<ModalContextProvider
ref={ref}
modal={modal}
modalProps={modalProps}>
<ModalContext.Consumer>
{({ openModal }) =>
<Button
onClick={() => openModal()}
{...props}>
{title}
</Button>
}
</ModalContext.Consumer>
</ModalContextProvider>
)
}
export const ModalButton = forwardRef(ModalButtonComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment