Skip to content

Open source library for managing component states (including mounting and unmounting) over time for css transitions and animations.

License

Notifications You must be signed in to change notification settings

nirtamir2/react-base-transition-group

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version

React Base Transition Group

Open source library for managing component states (including mounting and unmounting) over time for css transitions and animations.

Inspired by react-transition-group.

The main difference is that you don't have to use the and instead you Must add transition / animation in order to unmount a child component.

Install

yarn add react-base-transition-group

Usage

Edit gifted-beaver-27o7m

import cx from "classnames";
import { TransitionGroup, Status } from "react-base-transition-group";

function App() {
  const [notifications, setNotification] = React.useState([
    { id: 1, title: "A" },
    { id: 2, title: "B" },
  ]);

  return (
    <TransitionGroup
      items={notifications}
      renderItem={(notification, status) => {
        return (
          <div
            className={cx("App__notification", {
              "App__notification--enter": status === Status.ENTERED,
              "App__notification--exit": status === Status.EXITED,
            })}
          >
            {notification.title}
          </div>
        );
      }}
    />
  );
}

You can see the examples in the example folder. If you want the animation appear on the initial appear - you can set the prop initialStatus to be Status.ENTERED.

About

Open source library for managing component states (including mounting and unmounting) over time for css transitions and animations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published