Skip to content

Instantly share code, notes, and snippets.

@neolitec
neolitec / ReturnTypes.ts
Created February 7, 2020 15:45
ReturnTypes.ts
export type ReturnTypes<T> = {
[P in keyof T]: T[P] extends (...args: any[]) => any
? ReturnType<T[P]> extends PromiseLike<infer U>
? U
: ReturnType<T[P]>
: T[P];
};
@neolitec
neolitec / use-boolean-animation.ts
Last active July 17, 2020 20:12
React - useBooleanAnimation
import {Animated, Easing, EasingFunction} from 'react-native';
import {useEffect, useRef} from 'react';
const DEFAULT_ANIMATION_DURATION = 300;
const DEFAULT_EASING_FUNCTION = Easing.bezier(0.17, 0.67, 0.35, 0.92);
export function useBooleanAnimation(
value: boolean,
{
duration = DEFAULT_ANIMATION_DURATION,