This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BlurScrollTestScreen = () => { | |
const insets = useSafeAreaInsets(); | |
const [refreshing, setRefreshing] = useState(false); | |
const refresh = async () => { | |
setRefreshing(true); | |
setTimeout(() => { | |
setRefreshing(false); | |
}, 3000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PluralOptions = { | |
pluralForm?: string; | |
}; | |
export const formatPlural = ( | |
noun: string, | |
count: number, | |
options: PluralOptions = {} | |
) => { | |
return `${count} ${pluralize(noun, count, options)}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useRef, useEffect } from "react"; | |
// For wrapping state that is frequently updated, but used for an api, | |
// e.g. a text input hooked up to a search query. | |
export function useDebouncedTrigger<T>(trigger: T): T { | |
const [debouncedTrigger, setDebouncedTrigger] = useState(trigger); | |
const _timeout = useRef<NodeJS.Timeout | null>(null); | |
useEffect(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StyleSheet, ViewStyle } from "react-native"; | |
type ValueOf<T> = T[keyof T]; | |
type mapFunc<V extends ValueOf<ViewStyle>> = ( | |
key: string, | |
value: V | |
) => ViewStyle; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect, useRef } from "react"; | |
import { LayoutAnimation } from "react-native"; | |
/import { useState, useEffect, useRef } from "react"; | |
import { LayoutAnimation } from "react-native"; | |
/** | |
* | |
* Triggers a layout animation when the loading parameter changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef, useEffect } from "react"; | |
/** | |
* Returns a boolean ref to determine if the component is still mounted. | |
* Useful for (stopping) async logic that can't occur after a dismount. | |
*/ | |
export const useIsMounted = () => { | |
const mounted = useRef(true); | |
useEffect( | |
() => () => { |