Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Latest commit

 

History

History
69 lines (63 loc) · 1.44 KB

README.md

File metadata and controls

69 lines (63 loc) · 1.44 KB


InstallationExamplesDocumentation



Installation

First run the below commands to install the dependencies:

yarn add @reasonbr/bs-toastify -D
yarn add react-toastify

Import react-toastify's css somewhere in your code. You can use [%bs.raw] if you want to.

import "react-toastify/dist/ReactToastify.css";

Examples

open ReactToastify;

[@react.component]
let make = () => {
  let handleClick = () => {
    let cb = {
      Js.log("Cool");
      ();
    };
    toast->success(
      "Success",
      ReactToastify.options(
        ~autoClose=3000,
        ~hideProgressBar=false,
        ~closeOnClick=false,
        ~onClose=cb,
        (),
      ),
    );

    toast->warning(
      "Warning",
      ReactToastify.options(
        ~autoClose=3000,
        ~position=`topRight,
        ~hideProgressBar=false,
        ~closeOnClick=false,
        (),
      ),
    );
    ();
  };

  <>
    <ToastContainer position=`topRight autoClose=3000 transition=flip />
    <h1> {"Hello" |> ReasonReact.string} </h1>
    <button onClick={_ => handleClick()}>
      {"Click" |> ReasonReact.string}
    </button>
  </>;
};

let default = make;