- Instalar TypeScript y demás dependencias
npm i -D typescript @types/node ts-node-dev rimraf
- Inicializar el archivo de configuración de TypeScript ( Se puede configurar al gusto)
npx tsc --init --outDir dist/ --rootDir src
import React, { PropsWithChildren } from "react"; | |
import { renderHook, RenderOptions } from "@testing-library/react"; | |
import { Provider } from "react-redux"; | |
import { ToolkitStore } from "@reduxjs/toolkit/dist/configureStore"; | |
import type { AppStore } from "../../src/store"; | |
// This type interface extends the default options for render from RTL, as well | |
// as allows the user to specify other things such as store. | |
interface ExtendedRenderOptions extends Omit<RenderOptions, "queries"> { | |
store?: AppStore; |
export const timeSince = ( date: string ) => { | |
const baseDate = new Date(date) | |
const seconds = Math.floor(( new Date().getTime() - baseDate.getTime() ) / 1000); | |
let interval = seconds / 31536000; |
.table-container { | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
margin-top: 20px; | |
} | |
.table { | |
width: 100%; | |
max-width: 90vw; |
// biome-ignore lint/suspicious/noExplicitAny | |
export function debounce<T extends (...args: any[]) => void>(func: T, timeout = 300): (...args: Parameters<T>) => void { | |
let timer: NodeJS.Timeout | undefined; | |
return (...args: Parameters<T>) => { | |
clearTimeout(timer); | |
timer = setTimeout(() => { | |
func(...args); | |
}, timeout); | |
}; |