This file contains 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 type { JSX } from 'react'; | |
interface AwaitProps<T> { | |
promise: Promise<T>; | |
children: (result: T) => JSX.Element; | |
} | |
const Await = async <T,>({ promise, children }: AwaitProps<T>) => { | |
const result = await promise; |
This file contains 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
export const matched = param => ({ | |
on: () => matched(param), | |
otherwise: () => param, | |
}); | |
export const matchRedirect = param => ({ | |
on: (pred, fn) => (pred(param) ? matched(fn(param)) : matchRedirect(param)), | |
otherwise: fn => fn(param), | |
}); |
This file contains 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 { useEffect } from "react"; | |
import { useDebounce } from "hooks"; | |
const App = () => { | |
const debounce = useDebounce(); | |
useEffect(() => { | |
debounce(() => { | |
console.log('Hello world') |
This file contains 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'; | |
const useIsMountedRef = () => { | |
const isMounted = useRef(true); | |
useEffect(() => () => { | |
isMounted.current = false; | |
}, []); | |
return isMounted; |
This file contains 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 { setPayload } from './setPayload'; | |
/** | |
* Busca si el handler dado es una funcion, | |
* si lo es devuelve la función, si no lo es | |
* devuelve una función setPayload por defecto | |
* @param {function | string} actionHandler | |
* @returns {function} | |
* @private | |
*/ |