Files
DefinitelyTyped/types/react-transition-group/react-transition-group-tests.tsx
Yuki Nishijima 07847a4021 [react-transition-group] Add const for Transition (#24778)
This fixes the following TS errors:

  import Transition, { ENTERED, ENTERING } from 'react-transition-group/Transition'
  // => Module '"./node_modules/@types/react-transition-group/Transition"' has no exported member 'ENTERED'.
  // => Module '"./node_modules/@types/react-transition-group/Transition"' has no exported member 'ENTERING'.
2018-04-09 10:44:33 -07:00

83 lines
2.7 KiB
TypeScript

import * as React from "react";
import CSSTransition = require("react-transition-group/CSSTransition");
import Transition, { UNMOUNTED, EXITED, ENTERING, ENTERED, EXITING } from "react-transition-group/Transition";
import TransitionGroup = require("react-transition-group/TransitionGroup");
import Components = require("react-transition-group");
const Test: React.StatelessComponent = () => {
function handleEnter(node: HTMLElement, isAppearing: boolean) {}
function handleExit(node: HTMLElement) {}
function handleEndListener(node: HTMLElement, done: () => void) {
node.addEventListener("transitionend", done, false);
}
return (
<TransitionGroup
component="ul"
className="animated-list"
childFactory={ (child: React.ReactElement<any>) => child }
>
<Components.Transition
in
mountOnEnter
unmountOnExit
appear
enter
exit
timeout={ 500 }
addEndListener={ handleEndListener }
onEnter={ handleEnter }
onEntering={ handleEnter }
onEntered={ handleEnter }
onExit={ handleExit }
onExiting={ handleExit }
onExited={ handleExit }
>
<div>{ "test" }</div>
</Components.Transition>
<Transition
timeout={ { enter : 500, exit : 500 } }
>
<div>{ "test" }</div>
</Transition>
<Components.CSSTransition
in
mountOnEnter
unmountOnExit
appear
enter
exit
timeout={ 500 }
addEndListener={ handleEndListener }
onEnter={ handleEnter }
onEntering={ handleEnter }
onEntered={ handleEnter }
onExit={ handleExit }
onExiting={ handleExit }
onExited={ handleExit }
classNames="fade"
>
<div>{ "test" }</div>
</Components.CSSTransition>
<CSSTransition
timeout={ { enter : 500, exit : 500 } }
classNames={ {
appear: "fade-appear",
appearActive: "fade-active-appear",
enter: "fade-enter",
enterActive: "fade-active-enter",
exit: "fade-exit",
exitActive: "fade-active-exit"
} }
>
<div>{ "test" }</div>
</CSSTransition>
</TransitionGroup>
);
};