Skip to content

Instantly share code, notes, and snippets.

@jacobtoye
Created November 14, 2017 00:30
Show Gist options
  • Save jacobtoye/745c2fc2bccd532a10e15c889ea5bb40 to your computer and use it in GitHub Desktop.
Save jacobtoye/745c2fc2bccd532a10e15c889ea5bb40 to your computer and use it in GitHub Desktop.
import * as React from 'react';
import './styles.css';
export interface AnimationProps {
isAnimated?: boolean;
}
export const withAnimation = <T extends {}>(WrappedComponent: React.ComponentClass<T>) => {
return class extends React.Component<T & AnimationProps> {
render() {
// TODO: we should use an enum to determine the animation
const className = this.props.isAnimated ? 'fade-in-out' : '';
return (
<div className={className}>
<WrappedComponent {...this.props} />
</div>
);
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment