Last active
September 20, 2018 03:28
-
-
Save thulioph/315c068e85a9973b0f5018fba534b41e to your computer and use it in GitHub Desktop.
An example to demonstrate a Modal component made using Recompose
This file contains hidden or 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 React from "react"; | |
import { compose, withState, withHandlers } from "recompose"; | |
import { ModalComponent } from "./Modal"; | |
const hoc = compose( | |
withState("showModal", "updateModal", false), | |
withHandlers({ | |
onHandleModal: ({ updateModal, showModal }) => () => updateModal(!showModal), | |
onBtnSuccess: () => () => console.warn("Success"), | |
onBtnCancel: () => () => console.warn("Cancel") | |
}) | |
); | |
const ModalHOC = hoc(ModalComponent); | |
const modalProps = { | |
modalTitle: "My modal Title", | |
modalBody: "My modal body will be here!!!!", | |
mainBtnLabel: "open modal", | |
successBtnLabel: "Do something", | |
cancelBtnLabel: "Cancel bro" | |
}; | |
// <ModalHOC {...modalProps}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment