Skip to content

A tiny React mount/unmount transition manager with a familiar API.

Notifications You must be signed in to change notification settings

truework/mounty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3258e89 · Mar 16, 2023

History

44 Commits
Mar 16, 2023
Mar 16, 2023
Apr 28, 2022
Mar 16, 2023
Apr 28, 2022
Apr 28, 2022
Apr 28, 2022
Mar 16, 2023
Mar 16, 2023
Apr 28, 2022

Repository files navigation

mounty npm

A tiny React transition manager with mount/unmount support and a familiar API.

Install

npm i mounty --save

Usage

The code below is demoed here.

import { Mounty } from "mounty";

function App() {
  const [active, setActive] = React.useState(false);

  return (
    <>
      <button onClick={() => setActive(!active)}>Click to Pin</button>

      <Mounty in={active} timeout={400} shouldUnmount>
        {({ active, ready, entering, entered, exiting, exited }) => {
          return (
            <div
              style={{
                opacity: ready ? 1 : 0,
                transition: "opacity 400ms",
              }}
            >
              I'm automatically mounted & unmounted, and I fade in and out while
              doing it!
            </div>
          );
        }}
      </Mounty>
    </>
  );
}

render(<App />, document.getElementById("root"));

License

MIT License © Truework