Skip to content

Instantly share code, notes, and snippets.

View kgchicobava's full-sized avatar
💭
In vino veritas

Roman kgchicobava

💭
In vino veritas
View GitHub Profile

deepCompare performs a deep comparison of two objects. It automatically unwraps JS Maps, Sets, and ImmutableJS objects.

Example

deepCompare(left, right)

// Will output:
// {
// isEqual: false,
@migsc
migsc / useCollapsibleHeader.js
Created September 24, 2020 20:10
A React Native hook that helps build a scroll-bound collapsible header by providing the props for an Animated.View (header component) and an Animated.FlatList/Animated.ScrollView (list component).
import {useEffect, useRef} from 'react';
import {Animated} from 'react-native';
const {diffClamp} = Animated;
const useCollapsibleHeader = headerHeight => {
const listRef = useRef(null);
const scrollY = useRef(new Animated.Value(0));
const scrollYClamped = diffClamp(scrollY.current, 0, headerHeight);