diff --git a/packages/react-cookie/src/useCookies.tsx b/packages/react-cookie/src/useCookies.tsx index 83fe9bb..c01ddff 100644 --- a/packages/react-cookie/src/useCookies.tsx +++ b/packages/react-cookie/src/useCookies.tsx @@ -2,12 +2,12 @@ import { useContext, useEffect, useState, useRef, useMemo } from 'react'; import { Cookie, CookieSetOptions } from 'universal-cookie'; import CookiesContext from './CookiesContext'; -export default function useCookies( - dependencies?: string[] +export default function useCookies( + dependencies?: T[] ): [ - { [name: string]: any }, - (name: string, value: Cookie, options?: CookieSetOptions) => void, - (name: string, options?: CookieSetOptions) => void + U, + (name: T, value: Cookie, options?: CookieSetOptions) => void, + (name: T, options?: CookieSetOptions) => void ] { const cookies = useContext(CookiesContext); if (!cookies) { @@ -23,7 +23,7 @@ export default function useCookies( const newCookies = cookies.getAll(); if ( - shouldUpdate( + shouldUpdate( dependencies || null, newCookies, previousCookiesRef.current @@ -48,10 +48,10 @@ export default function useCookies( return [allCookies, setCookie, removeCookie]; } -function shouldUpdate( - dependencies: string[] | null, - newCookies: { [name: string]: any }, - oldCookies: { [name: string]: any } +function shouldUpdate( + dependencies: T[] | null, + newCookies: U, + oldCookies: U ) { if (!dependencies) { return true;