react-animate-hoc
v0.5.1
Published
Higher-order component easing/animating prop changes for React
Maintainers
Readme
react-animate-hoc
Higher-order component easing/animating prop changes for React
Demo
Live demo is available https://mleko.gitlab.io/react-animate-hoc/
Installation
Library can be installed via npm.
$ npm install react-animate-hocUsage
Component you wish to animate
export function ColorBox(p: RgbColor): JSX.Element {
let style = {
height: 50,
width: 50,
backgroundColor: `rgb(${p.r.toFixed()},${p.g.toFixed()},${p.b.toFixed()}`,
border: "1px black solid",
display: "inline-block",
margin: 3
};
return (<div style={style}/>);
}to animate property transition wrap component in animate HOC
export const AnimatedColorBox = animate()(ColorBox)or annotate new component
@animate()
export class AnnotatedColorBox extends React.Component<RgbColor, any> {
public render(): JSX.Element {
return (<ColorBox {...this.props}/>);
}
}Now you can use animated components just like regular one
<ColorBox {...this.state}/>
<AnimatedColorBox {...this.state}/>
<AnnotatedColorBox {...this.state}/>Running examples
Have node.js and npm installed.
- Clone this repo.
- Run
npm installto get all dependencies. - Run
npm startto run Webpack dev server.

