(
return (
<>
- (
+ WrappedComponent: ComponentType
+) {
+ return class WithMessage extends Component {
+ private opacity = new Animated.Value(0);
+
+ state: State = { message: undefined };
+
+ showMessage = (message: string) => {
+ this.setState({ message });
+ Animated.timing(this.opacity, {
+ toValue: 1,
+ duration: 80,
+ useNativeDriver: true,
+ }).start();
+ setTimeout(() => {
+ Animated.timing(this.opacity, {
+ toValue: 0,
+ duration: 120,
+ useNativeDriver: true,
+ }).start(e => {
+ if (e.finished) this.setState({ message: undefined });
+ });
+ }, 1600);
+ };
+
+ render() {
+ const { message } = this.state;
+ return (
+