UNPKG

react-native-multiple-modals

Version:

Native implementation with the ability to display multiple Modals

16 lines (11 loc) 366 B
import { useEffect, useRef } from 'react'; const getRandomId = (): string => Math.random().toString(36); export const useID = (defaultID?: string): string => { const idRef = useRef<string>(defaultID || getRandomId()); useEffect(() => { return () => { idRef.current = defaultID || getRandomId(); }; }, [defaultID]); return idRef.current; };