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

rescriptbr/rescript-toastify

Repository files navigation


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;

About

ReasonML bindings for react-toastify

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published