Duffer Derek

Current Path : /var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-dnd/src/hooks/
Upload File :
Current File : /var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-dnd/src/hooks/useOptionalFactory.ts

import { useMemo } from 'react'

import type { FactoryOrInstance } from './types.js'

export function useOptionalFactory<T>(
	arg: FactoryOrInstance<T>,
	deps?: unknown[],
): T {
	const memoDeps = [...(deps || [])]
	if (deps == null && typeof arg !== 'function') {
		memoDeps.push(arg)
	}
	return useMemo<T>(() => {
		return typeof arg === 'function' ? (arg as () => T)() : (arg as T)
	}, memoDeps)
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists