UNPKG

@re-flex/transition-group

Version:

Re-flex UI Transtion Controller Package

22 lines (21 loc) 596 B
import { cloneElement } from "react"; import useUseTransition, { Phase, } from "./useTransition"; const humanizePhaze = [ "appear", "appearing", "appeared", "enter", "entering", "entered", "exit", "exiting", "exited", ]; export default ({ children, alwaysMounted = false, ...props }) => { const [state, phase] = useUseTransition(props); return ((alwaysMounted || phase !== Phase.EXITED) && (typeof children === "function" ? children(state, humanizePhaze[phase]) : cloneElement(children, { phase }))); };