Skip to content

Instantly share code, notes, and snippets.

@thulioph
Last active September 20, 2018 03:28
Show Gist options
  • Save thulioph/315c068e85a9973b0f5018fba534b41e to your computer and use it in GitHub Desktop.
Save thulioph/315c068e85a9973b0f5018fba534b41e to your computer and use it in GitHub Desktop.
An example to demonstrate a Modal component made using Recompose
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