diff --git a/README.md b/README.md index 51e5035..c71f256 100644 --- a/README.md +++ b/README.md @@ -152,14 +152,13 @@ Same as [useAnimation](#useanimation), but it drives function not React element. ### useTransitionAnimation A hook to compose multiple [useAnimation](#useanimation) and plays them when element enter/update/exits. -This hook must be used under [AnimationGroup component](#animationgroup). +This hook must be used under [TransitionGroup component](#TransitionGroup). [Examples](./stories/hooks/useTransitionAnimation.stories.tsx) -### AnimationGroup +### TransitionGroup -A component to provide some behavior to its children. -Currently it only detects enter/update/exit of children by key, that works similar to [TransitionGroup of react-transition-group](https://reactcommunity.org/react-transition-group/transition-group). +A component to manage enter/update/exit of its children by key, that works similar to [TransitionGroup of react-transition-group](https://reactcommunity.org/react-transition-group/transition-group). ## Use polyfill diff --git a/src/react/components/AnimationGroup.tsx b/src/react/components/TransitionGroup.tsx similarity index 95% rename from src/react/components/AnimationGroup.tsx rename to src/react/components/TransitionGroup.tsx index 67c66da..b039db4 100644 --- a/src/react/components/AnimationGroup.tsx +++ b/src/react/components/TransitionGroup.tsx @@ -53,13 +53,13 @@ const Provider = ({ ); }; -export type AnimationGroupProps = { +export type TransitionGroupProps = { children: ReactElement | ReactElement[]; }; -export const AnimationGroup = ({ +export const TransitionGroup = ({ children, -}: AnimationGroupProps): ReactElement => { +}: TransitionGroupProps): ReactElement => { const elemsRef = useRef(null!); const prevElems = elemsRef.current || []; const elems = Children.map(children, (c) => c); diff --git a/src/react/components/index.ts b/src/react/components/index.ts index eb04975..47a47d2 100644 --- a/src/react/components/index.ts +++ b/src/react/components/index.ts @@ -1,2 +1,2 @@ -export { AnimationGroup } from "./AnimationGroup"; -export type { AnimationGroupProps } from "./AnimationGroup"; +export { TransitionGroup } from "./TransitionGroup"; +export type { TransitionGroupProps } from "./TransitionGroup"; diff --git a/src/react/hooks/useTransitionAnimation.ts b/src/react/hooks/useTransitionAnimation.ts index d8fd93c..140f36d 100644 --- a/src/react/hooks/useTransitionAnimation.ts +++ b/src/react/hooks/useTransitionAnimation.ts @@ -4,7 +4,7 @@ import { TransitionNotifierContext, TransitionState, TransitionStateContext, -} from "../components/AnimationGroup"; +} from "../components/TransitionGroup"; import type { AnimationHandle } from "./useAnimation"; import { AnimationController, diff --git a/stories/hooks/useTransitionAnimation.stories.tsx b/stories/hooks/useTransitionAnimation.stories.tsx index 38ac5df..49ec5fe 100644 --- a/stories/hooks/useTransitionAnimation.stories.tsx +++ b/stories/hooks/useTransitionAnimation.stories.tsx @@ -1,7 +1,7 @@ import { StoryObj } from "@storybook/react"; import React, { useEffect, useRef, useState } from "react"; import { - AnimationGroup, + TransitionGroup, AnimationOptions, useAnimation, useTransitionAnimation, @@ -61,11 +61,11 @@ export const Input: StoryObj = { setValue(e.target.value)} />
- + {value.split("").map((t, i) => ( {t} ))} - +
); @@ -133,13 +133,13 @@ export const Alphabet: StoryObj = { <> - + {texts.map((t, i) => ( {t} ))} - + @@ -230,11 +230,11 @@ export const Expand: StoryObj = { alignContent: "flex-start", }} > - + {expanded ? rects.map((i) => ) : []} - + );